Category Archives: Laravel

Laravel Tutorials

Laravel Dynamic Ajax Dependent Dropdown

In this Laravel dynamic dependent dropdown using ajax jquery tutorial I’ll show you how to create dynamic dependent dropdown using jquery ajax in laravel. In this tutorial you will learn to create ajax dynamic dependent dropdown using jquery ajax. In this article I’ll demonstrate how to show selected subcategories dependent dropdown on selected category dropdown using jquery ajax in laravel.

Laravel Dynamic Ajax Dependent Dropdown

  1. Step 1: Install Laravel New App
  2. Step 2: Add Database Details
  3. Step 3: Create Model and Migration
  4. Step 4: Add Routes
  5. Step 5: Create Controllers By Artisan
  6. Step 6: Create Blade Views
  7. Step 7: Run Development Server

Step 1: Install Laravel New App

First of all we need to create a fresh laravel project, download and install Laravel using the below command

Step 2: Add Database Details

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Step 3: Create Modal and Migration

Now, in this step we will create model and migration file. Please run the following command:

Navigate database/migrations/ and open create_categorys_table.php file. Then update the following code into this file:

Now, run the migration to create database table using following artisan command:

Next navigate to app and open Category.php model file. Then update the following code into your app/Category.php file as follow:

Step 4: Add Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Step 5: Create Controllers by Artisan

Now, lets create a controller named CategoryController using command given below –

This command will create CategoryController by the artisan command.

Now, go to app/http/controller and open CategoryController.php.Then put the following methods into your controller file:

Step 6: Create Blade Views

In this step, you need to create one blade views file for rendering data on it. So navigate to resources/views folder and create the blade view as following:

Create first file name category.blade.php and update the following code into it:

Step 7: Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Laravel 7 Vue JS Full Calendar Example

In this Laravel Vue js fullcalendar example tutorial I’ll show you how to display events on the calendar using vue js fullcalendar components in laravel apps. In this tutorial you will learn to display events on the calendar using vue js fullcalendar in laravel. This tutorial you will also learn to show dynamic event data on vue js calendar using Vue full calendar components in laravel vue js.

Laravel 7 Vue JS Full Calendar Example

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Create Model And Migration
  • Step 4: NPM Module Configuration For Vue Js
  • Step 5: Add Routes
  • Step 6: Create Controller By Command
  • Step 7: Create Vue Component
  • Step 8: Create Blade Views And Initialize Vue Components
  • Step 9: Run Development Server

Step 1: Download Laravel Fresh App

First of all we need to create a fresh laravel project, download and install Laravel using the below command

Step 2: Add Database Details

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Step 3: Create Model And Migration

Now, in this step we will create model and migration file. Please run the following command:

The above command will create one model name Event.php and also create one migration file for the events table. Now open create_events_table.php migration file from database>migrations and replace up() function with following code:

Now, run the migration to create database table using following artisan command:


Next, Navigate to app/Event.php and update the following code into your Event.php model as follow:

Step 4: NPM Module Configuration For Vue Js

Install all Vue dependencies:


After that, install vue full calendar dependencies by using the below command:

Step 5: Add Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Step 6: Create Controller By Command

Now, lets create a controller named EventController using command given below –

After that, go to app\Http\Controllers and open EventController.php file. Then update the following code into your EventController.php file:

Step 7: Create Vue Component

Now, go to resources/assets/js/components directory and create a file called FullCalendarComponent.vue.

Now, put the following code into your FullCalendarComponent.vue components file:

Now open resources/assets/js/app.js and include the FullCalendarComponent.vue component as follow:

Step 8: Create Blade Views And Initialize Vue Components

In this step, navigate to resources/views and create one folder named layouts. Inside this folder create one blade view file named app.blade.php file. Next, Navigate to resources/views/layouts and open app.blade.php file. Then update the following code into your app.blade.php file as follow:

Next, Navigate to resources/views/ and open welocome.blade.php. Then update the following code into your welcome.blade.php file as follow:

Step 9: Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Laravel 7 Vue JS Owl Carousel Slider Example

In this Laravel 7 Vue JS Owl Carousel Slider Example tutorial, I’ll show you how to implement Owl carousel slider with Vue Js in laravel. In this tutorial you will learn to create Owl carousel slider with Vue Js in laravel. With Owl carousel you can create image slider in laravel project.

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Create Model And Migration
  • Step 4: NPM Module Configuration For Vue Js
  • Step 5: Add Routes
  • Step 6: Create Controller By Command
  • Step 7: Create Vue Component
  • Step 8: Create Blade Views And Initialize Vue Components
  • Step 9: Run Development Server

Step 1: Download Laravel Fresh App

First of all we need to create a fresh laravel project, download and install Laravel using the below command

Step 2: Add Database Details

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Step 3: Create Model And Migration

Now, in this step we will create model and migration file. Please run the following command:

This command will create one model name slider.php and also create one migration file for the sliders table.

Now open create_sliders_table.php migration file from database>migrations and replace up() function with following code:

Now, run the migration to create database table using following artisan command:


Next, Navigate to app/Slider.php and update the following code into your Slider.php model as follow:

Step 4: NPM Module Configuration For Vue Js

Install all Vue dependencies:


Now, we will install owl carousel dependencies by using the below command:

Step 5: Add Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Step 6: Create Controller By Command

Now, lets create a controller named SliderController using command given below –

After that, go to app\Http\Controllers and open SliderController.php file. Then update the following code into your SliderController.php file:

Step 7: Create Vue Component

Next step, go to resources/assets/js/components folder and create a file called SliderComponent.vue.

Now, update the following code into your SliderComponent.vue components file:

Now open resources/assets/js/app.js and include the SliderComponent.vue component as follow:

Step 8: Create Blade Views And Initialize Vue Components

In this step, navigate to resources/views and create one folder named layouts. Inside this folder create one blade view file named app.blade.php file.

Now, go to resources/views/layouts and open app.blade.php file. Then put the following code into your app.blade.php file as follow:

Next, Navigate to resources/views/ and open welocome.blade.php. Then update the following code into your welcome.blade.php file as follow:

Step 9: Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Laravel 7 Vue JS Live Search Example Tutorial

In this Laravel 7 Vue JS Live Search Example Tutorial, I’ll show you how to implement live search with Vue Js In laravel. In this tutorial you will learn to implement live search with Vue Js in laravel application.

Laravel 7 Vue JS Live Search Example Tutorial

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Run Make auth Command
  • Step 4: Create Model And Migration
  • Step 5: NPM Configuration
  • Step 6: Add Routes
  • Step 7: Create Controller By Command
  • Step 8: Create Vue Component
  • Step 9: Create Blade Views And Initialize Vue Components
  • Step 10: Run Development Server

Step 1: Download Laravel Fresh App

First of all we need to create a fresh laravel project, download and install Laravel using the below command

Step 2: Add Database Details

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Step 3: Run Make auth Command

In this step we will setup laravel default auth using following command:

Step 4: Create Model And Migration

Now, in this step we will create model and migration file. Please run the following command:

This command will create one model name post.php and also create one migration file for the posts table. Now open create_posts_table.php migration file from database>migrations and replace up() function with following code:

Now, run the migration to create database table using following artisan command:


Next, Navigate to app/Post.php and update the following code into your Post.php model as follow:

Next, Navigate to database/factories and open PostFactory.php. Then update the following code into it as follow:

and then run the following command to generate fake data using faker as follow:

Step 5: NPM Configuration

Now we will configure NPM using following command:

Install all Vue dependencies:

Step 6: Add Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Step 7: Create Controller By Command

Now, lets create a controller named PostController using command given below –

After that, go to app\Http\Controllers and open PostController.php file. Then update the following code into your PostController.php file:

Step 8: Create Vue Component

Next step, go to resources/assets/js/components folder and create a file called SearchComponent.vue.

Now, update the following code into your SearchComponent.vue components file:

Now open resources/assets/js/app.js and include the SearchComponent.vue component as follow:

Step 9: Create Blade Views And Initialize Vue Components

In this step, navigate to resources/views and create one folder named layouts. Inside this folder create one blade view file named app.blade.php file.

Next, Navigate to resources/views/layouts and open app.blade.php file. Then update the following code into your app.blade.php file as follow

Next, Navigate to resources/views/ and create one file name search.blade.php. Then update the following code into your search.blade.php file as follow:

Step 10: Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Laravel 7 Database Backup Example Tutorial

In this laravel database backup tutorial, I’ll show you how to take backup of database in laravel apps. In tutorial you will learn to take database backup in laravel application. This tutorial will help you step by step to take database backup daily, hourly, weekly, and monthly in laravel apps using the database package.

Laravel 7 Database Backup Example Tutorial

Step 1: Install Package

Step 2: Add ServiceProvider

Next step, Navigate to config/app.php file. And then add service provider as follow:

Step 3: Publish Vendor Of Package

Note that, Navigate to app/config/laravel-backup.php, and change configuration details.

Step 4: Backup With Command

Now run the command given below to download database backup into storage/app/backupfile:

Go to storage/app/backupfile in your storage directory.

Laravel 7 Daily Automatic Database Backup Example

In this laravel daily automatic database backup example tutorial, I’ll show you how to take daily automatic backup of database in laravel apps. In this tutorial you will learn to take Daily Automatic Database Backup in laravel.

Laravel 7 Daily Automatic Database Backup Example

In this step by step tutorial I’ll guide you through the process to take daily automatic database backup in laravel. Pleasae Follow the instruction given below and take daily automatic database backup in laravel apps using schedular cron job:

Step 1: Create Command

In this step we will switch to project directory as following:

Then use the below command to create command:

The above command creates one file named DbBackup.php.

Step 2: Register Command In “Kernel.php”

In this step we will register command, go to app/console and open kernal.php file. And then put the following code into your file:

Step 3: Edit the “ DbBackup.php”

Now, Navigate to app/Console/Commands/ folder and open DbBackup.php. And then update the following code into your file

Step 4: Backup Files

The above-created Laravel scheduler command which will take backup of database in zipped format and place file at “storage/app/backup”. So you can navigate storage/app/backup folder and find daily database backup files here.

 

Laravel 7 Form Validation Request Class Example

In this Laravel 7 Form Validation Request Class Example tutorial, I’ll show you how to validate form data using request class in laravel apps. In laravel request validation class is used to validate form data on server in laravel apps. This step by step tutorial we will be creating request validation class and validate form data on server side in laravel apps.

Laravel 7 Form Validation Request Class Example

Step 1: Create Request Class

Next, run the following command to create validate request class in laravel:

Now, go to app/Http/Requests and open ValidateUser.php class. Then update the following code into ValidateUser.php Class file:

Step 2: Add Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Step 3: Create Controller

Now, lets create a controller named UserController using command given below –

Now, navigate to app/Http/Controllers and open UserController.php file. Then update the following code into your UserController.php file:

Step 4: Create Blade View

In this step, we will create a blade view file named createUser.blade.php. Go to resources/views/ folder and create blade view file here. Then put the following code into your createUser.blade.php file:

Laravel 7 Unique Validation Example Tutorial

In this Laravel 7 Unique Validation Example Tutorial I’ll show you how to implement unique validations in laravel. In this tutorial you will learn add unique validation in laravel fields. In this step by step tutorial I’ll demonstrate various example to implement unique validation in laravel.

Laravel 7 Unique Validation Example Tutorial

  • Simple Unique Validation on Controller
  • Unique Validation with Column Name
  • Unique Validation with Rule
  • Laravel Unique Validation on Update

1: Simple Unique Validation on Controller

In laravel when you insert data into table but you want to check data is exist or not. So you can use simple unique validation in laravel. The following unique validation rule is simple. And you can use it as follow:

2: Unique Validation with Column Name

In laravel it is possible to pass column name along with the unique validation. Please have look in below example code.

3: Unique Validation with Rule

Before using unique validation with the rule, you need to import use Illuminate\Validation\Rule;. Then you can use it as follow:

4: Laravel Unique Validation on Update

In this example we have demonstrate to implement unique validation on update operation in laravel.

Laravel 7 Soft Delete With Unique Validation

In this Laravel 7 Soft Delete With Unique Validation I’ll show you how add soft delete with unique validation in laravel. In this tutorial you will learn to implement and use soft delete property in laravel. In this step by step guide I’ll demonstrate you to implement and use soft delete in laravel project.

Laravel 7 Soft Delete With Unique Validation

Laravel Unique Validation with Soft Delete

In this example you will learn to add unique validation with soft delete on inserting of data in laravel.

Example 1: On inserting data

Example 2: On updating data

In this example you will learn to add unique validation with soft delete on updating of data in laravel.

Laravel Redirect HTTP to HTTPS using htaccess

In this Laravel Redirect HTTP to HTTPS using htaccess tutorial I’ll show you how to redirect http to https using htaccess file in laravel. In this tutorial, you will learn how to redirect HTTP to HTTPS your laravel website with .htaccess.

Laravel Redirect HTTP to HTTPS using htaccess

Sometimes, when you need to secure your laravel web with an SSL certificate. When you have applied ssl certificate to your laravel application. Then you are required to your existing http urls to https version of urls in order to secure access of your application. In laravel urls with HTTP  will not be redirected automatically to HTTPS after you apply SSL certificate.

In laravel it is possible to redirect existing http links to https urls automatically with htaccess file. To do so you have to do some configuration in the .htaccess file of Laravel App. Then it will automatic redirect http request to Https in laravel web app.

Navigate to your laravel root directory and find .htaccess file. After that open .htaccess file and update the following codes into it:

Laravel 7 Phone Number Validation Example

In this Laravel 7 Phone Number Validation Example tutorial I’ll show you how to create custom phone number validation in laravel. In this tutorial you will learn to create phone number validation in laravel. In step by step tutorial I’ll demonstrate you to implement custom phone number validation in laravel.

Laravel 7 Phone Number Validation Example

Step 1: Add Routes

In this step we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Step 2: Create Controller & Method

Now, lets create a controller named UserController using command given below –

This command will create controller named UserController.php file. So navigate to app\Http\Controllers folder and open UserController.php file. Then update the following methods into it:

Step 3: Create Blade View

Now, Navigate to resources/views and create new blade view file named user.blade.php and update the following code into it:

The below also provide a different way for laravel phone number validation methods, you can also use instead of the above methods:

Laravel 7 Push Notification to Android and IOS Example

In this Laravel 7 Push Notification to Android and IOS Example tutorial, I’ll show you how to send push notification to android and Ios in laravel. In this tutorial you will learn send push notification in laravel project. In this step by step guide I’ll demonstrate you the process to send push notification in laravel.

Laravel 7 Push Notification to Android and IOS Example

Step 1: Create a Helper File

In this step we will create a helper file. Go to App directory and inside this directory create a new file new helpers.php. Now put the following code into your helpers.php file as follow:

app/helpers.php

Step 2: Add Fcm Key in .env

In this step we will add fcm key in laravel project’s .env file. Go to your project root directory and open .env file. Then update fcm key as follow:

Now, you can use your google fcm key as follow

Step 3: Send Notification

In this step, open your controller file and you can call send_notification_FCM($notification_id, $title, $message, $id,$type) from helpers.php with following parameters.

send_notification_FCM() with following parameter $notification_id, $title, $message, $id,$type. Now when you want to send push notification you need to call the send_notification_FCM() with parameters as specified.