Category Archives: Laravel

Laravel Tutorials

Laravel 8 Bootstrap Auth Scaffolding Example

In this Laravel 8 Bootstrap Auth Scaffolding Example Tutorial I will show how to create login, register, logout, forget password, profile and reset password page using laravel Bootstrap Auth Scaffolding without using laravel 8 make:auth command. Bootstrap Auth Scaffolding enable us to generate default laravel authentication scaffolding. Bootstrap Auth Scaffolding includes fully functional login, register, logout, reset password, forget password, email verification, two-factor authentication, session management.

In this laravel 8 Bootstrap Auth Scaffolding tutorial I will show you hot to use Bootstrap Auth Scaffolding to create auth scaffolding in laravel 8. Bootstrap Auth Scaffolding will include login, register, reset the password, forget password, email verification, and two-factor authentication blade views and controller file.

In this laravel 8 bootstrap auth example tutorial, I will show you how to use laravel Ui and bootstrap auth to implement default login, register, reset the password, forget password, email verification, and two-factor authentication blade views and controller file.

Laravel 8 Bootstrap Auth Scaffolding Example

In this step by step laravel 8 bootstrap auth example tutorial we will learn how to implement or generate Auth Scaffolding using laravel ui and bootstrap auth. Please follow the instruction given below:

  • Step 1 – Install Laravel 8 App
  • Step 2 – Database Configuration
  • Step 3 – Install Laravel UI
  • Step 4 – Install Bootstrap Auth Scaffolding
  • Step 5 – Install Npm Packages
  • Step 6 – Run PHP artisan Migrate
  • Step 7 – Run Development Server

Step 1 – Install Laravel 8 App

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

Step 2 – Database Configuration

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 – Install Laravel UI

Now, switch the laravel project directory and run the following composer command to install laravel/ui package. Laravel UI is an official library that offers selective or predefined UI components. The laravel/ui package comes with the login and registration scaffolding for React, Vue, jQuery, and Bootstrap layouts. Run the following composer command to install Laravel/UI.

Step 4 – Install Bootstrap Auth Scaffolding

Use the following artisan command to Install the auth scaffoldings with Bootstrap.

Now, you have successfully installed bootstrap in your laravel 8 project, you can see your resource directory js folder.

Step 5 – Install Npm Packages

Now, you need to install the bootstrap package and the related frontend dependencies such as jquery from npm using the following command:

Then type the following command on cmd to run npm:

Step 6 – Run php artisan Migrate

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

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 8 Multi Authentication Example Tutorial

In this Laravel 8 Multi Authentication Example Tutorial I’ll show you how to create multi auth system using middleware in laravel 8. In Laravel Multiple authentication system multiple users can log in in one application according to their roles.

While developing a laravel application there comes situations where we want create separate user login or separate user/admin panel for users having different privileges or access rights in same application. In this laravel multi auth system, In this example we will create a middleware for checking the user’s role. It is an admin or normal user. We will create middleware name admin and configuration in the kernal.php file and also in the route file.

Laravel 8 Multi Authentication Example Tutorial

In this step by step Laravel 8 Multi Authentication Example we will learn to implement multi auth system using middleware in laravel 8.

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Setting up migration and model
  • Step 4: Create Middleware and Setting up
  • Step 5: Define Route
  • Step 6: Create Methods in Controller
  • Step 7: Create Blade View
  • Step 8: Start Development Server

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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. Setting up migration and model

In this step we will add is_admin column in the users table using laravel mirgration. So, Open the creates_users_table.php migration file, which is placed on Database/migration and update the following field for admin.

Next open app/User.php and update the below field name is_admin here:


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

Step 4: Install Laravel UI

Then install laravel 8 UI in your project using the below command:

Now, execute the below command on terminal for creating login, registration, forget password and reset password blade files:

Then execute the following commands:

Step 5: Create Middleware and Setting up

In this step we will create middleware for checking the user’s role. It is an admin or normal user.

Once the above command is executed a middleware is created. Noe go to app/Http/middleware and Implement the logic to check user role.


Now, we will register this middleware in the app/Http/Kernel.php. Now, open kernal.php and add the following $routeMiddleware property in it:

Step 5: Define Route

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 Methods in Controller

Now open the HomeController.php file, which is placed on app/Http/Controllers/ directory. Then add the following code into it:

Step 7: Create Blade View

Now, create two blade view files first is display home page and second is display after login. Open the resources/views/home.blade. file and update the below code.

Now, I checked the user profile. If it is admin, it will navigate to the admin area. Otherwise, it will redirect to users area. Create admin.blade.php file inside resources/views/ directory and update the following code:

Step 8: Run development server

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

Laravel 8 Highcharts Example Tutorial

n this Laravel 8 Highcharts Example Tutorial I will show you how to implement highchart in laravel 8 application. In this tutorial you will learn to implement highchart in laravel 8. In this example I will demonstrate the use of highchart in laravel application. In this example we will fetch month wise data and display month wise data in highcharts for analytics on laravel application.

Laravel 8 Highcharts Example Tutorial

In this step by step tutorial I will demonstrate you how to implement Highcharts in Laravel 8 application. Please follow the instruction given below:

Step 1: Create web routes

In the first step we will 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

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

Once the above command executed, it will create a controller file HighChartController.php in app/Http/Controllers/ directory. Open the HighChartController.php file and put the following code in it.

app/Http/Controllers/HighChartController.php

Step 3: Create Blade File

Now, we will create a blade view file. Go to the resources/views/highchart.blade.php and put the below javascript and HTML code for displaying the highchart. So go to the resources/views/ and update the below javascript and HTML code for displaying the highchart:


Remember to include highchart js libraries on your blade file:


Use below javascript as per requirement :

Step 4: 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 8 Google Line Chart Tutorial Example

In this Laravel 8 Google Line Chart Tutorial Example I’ll will show how to use google line chart in laravel application. In this tutorial you will learn to implement google line char in laravel 8 project. With Google Charts we can visualize data in your laravel web application. In this tutorialI’ll share example to demonstrate use of google line graph chart in laravel.

Laravel 8 Google Line Chart Tutorial Example

In this step by step tutorial I will demonstrate you how to create google line chart in laravel 8 application. Please follow the instruction given below:

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Make Routes
  • Step 4: Create Controller
  • Step 5: Create Blade File
  • Step 6: Run Development Server

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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: Make 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 4: Create Controller

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

Now, go to app/http/controller folder and open GoogleLineController.php. And add the following code into your GoogleLineController.php file:

Step 5: Create Blade File

In this step we will create blade view file. Go to /resources/views/ folder and create one blade view file name google-line-chart.blade.php. And put the following code into your google-line-chart.blade.php file:

Step 6: 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 8 Dynamic Google Pie Charts Example

In this Laravel 8 Dynamic Google Pie Charts Example Tutorial I’ll will show how to use google Pie chart in laravel 8 application. In this tutorial you will learn to implement google Pie chart in laravel 8 project. With Google Charts we can visualize data in your laravel web application. In this tutorialI’ll share example to demonstrate use of google Pie chart in laravel.

Laravel 8 Dynamic Google Pie Charts Example

In this step by step tutorial I will demonstrate you how to create Dynamic Google Pie Charts in laravel 8 application. Please follow the instruction given below:

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Make Routes
  • Step 4: Create Controller
  • Step 5: Create Blade File
  • Step 6: Add Google Chart Library
  • Step 7: Run Development Server

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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: Make 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 4: Create Controller

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

Then go to app/http/controller folder and open GooglePieController.php. And put the following code into your GooglePieController.php file:

Step 5: Create Blade File

In this step we will create blade view file. Go to /resources/views/ folder and create one blade view file name google-pie-chart.blade.php. And put the following code into your google-pie-chart.blade.php file:

Step 6: Add Google Chart Library

Please remember to add google chart library.

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 8 Google Bar Chart Tutorial Example

In this Laravel 8 Google Bar Chart Tutorial Example I’ll will show how to use google Bar chart in laravel 8 application. In this tutorial you will learn to implement google Bar char in laravel 8 project. With Google Charts we can visualize data in your laravel web application. In this tutorialI’ll share example to demonstrate use of google Bar chart in laravel 8.

Laravel 8 Google Bar Chart Tutorial Example

In this step by step tutorial I will demonstrate you how to create google Bar char in laravel 8 application. Please follow instruction given below:

  • Step 1: Install Laravel App
  • Step 2: Add Database Details
  • Step 3: Generate Migration & Model File
  • Step 4: Add Route
  • Step 5: Create Controller
  • Step 6: Create Blade File
  • Step 7: Run Development Server

Step 1: Install Laravel App

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

Step 2: Add Database Configuration

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: Generate Migration & Model File

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

Now, go to app directory and open Order.php file. And put the following code into your Order.php file:


Now, go to database/migrations/ and open create_orders_table.php file and update the following code:


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

Step 4: Add Route

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 Controller

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

Then go to app/http/controller folder and open OrderController.php. And put the following code into your OrderController.php file:

Step 6: Create Blade File

In this step we will create blade file. Go to /resources/views/ folder and create one blade view file name google-bar-chart.blade.php. And add the following code into your google-bar-chart.blade.php file:

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 –

Instamojo Payment Gateway Integration In Laravel 8

In this Laravel 8 Instamojo Payment Gateway Integration Example tutorial I will show you How to Integrate Instamojo Payment Gateway in Laravel 8. In this tutorial, we will learn how to integrate the instamojo payment gateway in the php laravel 8 application via the instamojo PHP package.

Instamojo Payment Gateway

Instamojo is one of the popular payment gateway, that allows us to accept payment from your customer. Instamojo is very simple, hassle free and easy to integrate payment gateway.  Instamojo processes refund payments, collect a payment, create payment are very easy and simple.

Instamojo Payment Gateway Integration In Laravel 8

In this step by step tutorial I will demonstrate you to integrate instamojo payment gateway in the laravel 8 application without using curl APIs. We will simply install instamojo PHP package and integrate into our lastest laravel based application.

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Install Instamojo PHP package
  • Step 4: Configure Instamojo Package
  • Step 5: Make Model and Migration
  • Step 6: Create Controller
  • Step 7: Make Routes
  • Step 8: Create Blade View file
  • Step 9: Start Development Server

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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: Install Instamojo PHP package

In this step, we will install Instamojo PHP package via the composer dependency manager. Use the following command to install Instamojo PHP package.

Step 4: Configure Instamojo Package

Now, we will put following configuration detail in .env file:

Next, Go to the app/config/services.php and put the below code here.

Step 5: Make Model & Migration

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

Once above command is executed there will be a migration file created inside database/migrations/ directory, just open migration file and update the function up() method as following:

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

Step 6: Create Controller

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

Go to app/Http/Controller/PayController.php and put the below code :

Step 7: Make 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 8: Create Blade View file

In this step we will create blade file. Go to resources/views directory and create blade view file name event.blade.php. Then put the following code into event.blade.php:

Step 9: Start 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 8 User Roles and Permissions Tutorial Example

In this Laravel 8 user roles and permissions tutorial example I will show you how to implement user roles and permissions system in laravel 8 spatie/laravel-permission package. In this tutorial you will learn to create user roles and permission in laravel 8 application. We will be using spatie/laravel-permission package to create user roles and permission in laravel 8 application. The Spatie role permission package provide way to implement acl in laravel 8 application. With spatie we can create different user roles, user levels with specific permission.  With spatie we can assign user role, assign permission to user and assign permission to roles. In this example we will be using bootstrap auth scaffolding for login, register, logout, forget password, profile and reset password page.

Laravel 8 User Roles and Permissions Tutorial Example

In this step by step tutorial I will demonstrate you how to create or assign different user roles and user permission using laravel Spatie package. Please follow instructions given below:

Step 1 – Install Laravel 8 App

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

Step 2 – Database Configuration

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 – Install Spatie Composer Packages

In this step, we will install spatie/laravel-permission Package via the composer dependency manager. Use the following command to install spatie/laravel-permission Package.

After Installing Image intervention package, we need to add service provider in config/app.php file as following.

Now, run the following command to publish spatie package dependencies:

Step 4 – Create Model and Migration

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

Now, open migration file name create_products_tables.php and add the follwoing code into it:


Now, put the following code into Product.php file:


Then, put the following code into User.php:

Step 5 – Register Middleware

Now we will register a middleare as following

Step 6 – Create 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 Controllers

Now, lets create some controller using command given below –

Then open UserController.php file and add the following code into it, which is placed on app/http/controllers directory:


Then open RoleController.php file and add the following code into it, which is placed on app/http/controllers directory:


Then open ProductController.php file and add the following code into it, which is placed on app/http/controllers directory:

Step 8 – Install Laravel UI

In this step we will install laravel UI using following command:

Step 9 – Install Bootstrap Auth Scaffolding

Now, we will install bootstrap auth scaffolding using following command:

Step 10 – Install Npm Packages

Now install npm dependencies using following command:

Now, open terminal and type the following command on terminal to create tables in database:

Step 11 – Create Blade Views

Now, In this step we will create following blade views file:

  • Layout
    • app.blade.php
  • Users Module
    • index.blade.php create.blade.php edit.blade.php show.blade.php
  • Roles Module
    • index.blade.php create.blade.php edit.blade.php show.blade.php
  • Product Module
    • index.blade.php create.blade.php edit.blade.php show.blade.php

Now, create and open app.blade.php file and add the following code into it, which is places inside resources/views/layouts directory:

Then create users directory inside resources/views directory.

Now, create and open index.blade.php file and add the following code into it, which is placed on resources/views/users directory:

Now, create and open create.blade.php file and add the following code into it, which is placed on resources/views/users directory:


Now, create and open edit.blade.php file and add the following code into it, which is placed on resources/views/users directory:


Now, create and open show.blade.php file and add the following code into it, which is placed on resources/views/users directory:



Now, create Roles directory inside resources/views directory.

Now, create and open index.blade.php file and add the following code into it, which is placed on resources/views/roles directory:

Now, create and open create.blade.php file and add the following code into it, which is placed on resources/views/roles directory:


Now, create and open edit.blade.php file and add the following code into it, which is placed on resources/views/roles directory:


Now, create and open show.blade.php file and add the following code into it, which is placed on resources/views/roles directory:


Then create Product directory inside resources/views directory.

Now, create and open index.blade.php file and add the following code into it, which is placed on resources/views/product directory:


Now, create and open create.blade.php file and add the following code into it, which is placed on resources/views/product directory:


Now, create and open edit.blade.php file and add the following code into it, which is placed on resources/views/product directory:


Now, create and open show.blade.php file and add the following code into it, which is placed on resources/views/product directory:

Step 12 – 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 8 Livewire Add or Remove Dynamically Input Fields Tutorial

In this Laravel 8 Livewire Add or Remove Dynamically Input Fields Tutorial I’ll show you how to add or remove input fields dynamically using livewire in laravel 8. In this tutorial you will learn to create add or remove input fields dynamically using livewire in laravel 8 application. In this article I will share example to add or remove input fields dynamically using livewire in laravel 8 application

Laravel 8 Livewire Add or Remove Dynamically Input Fields Tutorial

In this step by step tutorial I will demonstrate you how to add or remove input fields dynamically using livewire in laravel 8 application. Please follow the instruction given below:

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Create Model & Migration using Artisan
  • Step 4: Install Livewire Package
  • Step 5: Build Livewire Component using Artisan
  • Step 6: Create Route
  • Step 7: Create View File
  • Step 8: Run Development Server

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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 Migration

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

The above command will create a model name Employee.php, and create a migration that name create_employees_table.php. Go to database/migrations folder and open create_ employees_table.php file. Then put the following code into create_ employees_table.php file:

Next, open your command prompt and run the following command to create the table into your database:


Now, go to app/Models/ directory and open Employee.php file. Then put the following code into it:

Step 4: Install Livewire Package

In this step, we will install Livewire Package via the composer dependency manager. Use the following command to install Livewire Package.

Step 5: Build Livewire Component using Artisan

In this step we will create a component using following artisan command:

The above command will create a components on the following path:

Now, go to app/Http/Livewire folder and open Employees.php file. Then add the following code into your Employees.php file:

Now, go to resources/views/livewire folder and open employees.blade.php file. Then put the following code into your employees.blade.php file:

Step 6: Create Route

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 View File

In this step we will create view file. Go to resources/views/ folder and create one blade view files that name home.blade.php file. Then add the following code into your home.blade.php file:

Step 8: 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 8 Dynamically Add or Remove Multiple Input Fields using jQuery

In this Laravel 8 Dynamically Add or Remove Multiple Input Fields using jQuery tutorial I’ll show you how to dynamically add or remove multiple input field in form using jQuery in laravel 8. In this tutorial you will learn to dynamically add or remove multiple input field in form using jquery in laravel 8. In this tutorial I’ll share example to demonstrate Dynamically Add or Remove multiple Input Fields jQuery.

Laravel 8 Dynamically Add or Remove Multiple Input Fields using jQuery

In this step by step tutorial we will learn to dynamically add or remove multiple input field in form using jQuery in laravel 8. Please follow the instruction given below:

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Build Migration & Model
  • Step 4: Add Routes
  • Step 5: Create Controller by Artisan
  • Step 6: Create Blade View
  • Step 7: Run Development Server
  • Step 8: Test App On Browser

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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: Build Migration & Model

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

Now, go to database/migrations folder and open create_todos_table.php. Then put the following code into create_todos_table.php:


Then open Todo.php file and the fillable property, which is placed on app/models directory:


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

Step 4: Create Route

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 Controller by Artisan

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

This command will create a controller named DynamicAddRemoveFieldController.php file.

Next, Navigate to app/http/controllers/ folder and open DynamicAddRemoveFieldController.php. Then add the following file uploading methods into your DynamicAddRemoveFieldController.php file:

Step 6: Create Blade View

In this step, we will create a blade view file named add-remove-multiple-input-fields.blade.php. Now, go to resources/views and create one file name add-remove-multiple-input-fields.blade.php Then put the following code into your add-remove-multiple-input-fields.blade.php file:

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 8 Integrate Summernote Tutorial Example

In this Laravel 8 Integrate Summernote Tutorial Example Tutorial I’ll show you how to install and use Summernote editor in laravel 8. In this tutorial you will learn to install and use Summernote editor in laravel 8.

While creating forms we come to situation where we may text editor field so that we can insert and save html and other text into database. The summernote editor is feature rich wysiwyg html editor allows us to integrate text editor fields in html form. In this laravel 8 summernote editor integration example I will guide you through step by step to install and use summernote wysiwyg editor in laravel 8 application.

Laravel 8 Integrate Summernote Tutorial Example

In this step by step tutorial I will demonstrate you how to install and use summernote wysiwyg editor in laravel 8 application. Please follow the instruction given below:

  • Step 1: Install Laravel 8 App
  • Step 2: Connecting App to Database
  • Step 3: Create Migration and Model File
  • Step 4: Add Routes
  • Step 5: Create Controller
  • Step 6: Create Blade File
  • Step 7: Run Development Server
  • Step 8: Test App

Step 1: Install Laravel 8 App

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

Step 2: Connecting App to Database

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 Migration and Model File

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

Now, go to database/migrations and open create_posts_table.php. Then update the following code into create_posts_table.php file, as follow:


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

The above command will create tables in your database. Then open Post.php model file and put the following code into Post.php model file, which is placed on App/Models directory:

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 Controller

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

Now, go to app/http/controllers and open PostController.php file. And put the following code into your PostController.php file, as follow:

Step 6: Create Blade File

In this step we will create blade file. Now, go to resources/views folder. And create 2 blade views that named display.blade.php and create.blade.php the file inside this folder. Then open create.blade.php file and update the following code into create.blade.php file, as follow:

Now open display.blade.php file and update the following code into your list.blade.php file, as follow:

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 8 Ajax CRUD with Image Upload Tutorial

In this Laravel 8 Ajax Crud with Image Upload Example tutorial, I’ll show you how to create basic CRUD application with Image upload using DataTables in laravel 8. In this tutorial you learn to create simple CRUD application with image upload using DataTables. In this step by step tutorial we will be creating simple crud application with image upload using DataTables in laravel.

Laravel 8 Ajax CRUD with Image Upload Tutorial

In this step by step guide, we will be creating a simple laravel 8 application to demonstrate you how to install yajra datatable package and implement ajax based CRUD operations with datatable js.

  • Step 1 – Install laravel 8 App
  • Step 2 – Connecting App to Database
  • Step 3 – Create Migration And Model
  • Step 4 – Install Yajra DataTables In App
  • Step 5 – Add Routes
  • Step 6 – Create Controller
  • Step 7 – Create Blade View
  • Step 8 – Run Development Server

Step 1 – Install Fresh Laravel Setup

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

Step 2 – Connecting App to Database

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 Migration And Model

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

Now, go to database/migrations/ and open create_products_table.php file. Then put the following code into this file:

Now, run following command to migrate database schema.

Now, go to App directory and open Product.php file and then put the following code to into Product.php file as follow:

Step 4 – Install Yajra Datatables Package in Laravel

In this step, we will install Yajra Datatables Package via the composer dependency manager. Use the following command to install Yajra Datatables.

After installing Yajra Datatables Packages in your laravel application. Open config/app.php file and add service provider and alias

After set providers and aliases then publish vendor run by following 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

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

Next navigate to app/Http/Controllers and open ProductController.php file. Then update the following methods for add products, edit product and delete the product into this controller file:

The Product Controller, will include following methods:
Index() :-  The index method will be used to display list of all products.
Store() :- The store method will be used to save and update the product into a database.
Edit() :- The edit method will be used to edit product detail.
Destroy() :- The delete method will be used to delete product from list and database as well.

Now, update all methods into your ProductController.php file as follow:

Step 7 – Create Blade View

Create the directory and create blade view file for CRUD operations as following: Now, Navigate to resources/views directory and create action.blade.php file.

Next, create a list.blade.php file inside resources/views/ folder and update the below code in your product list file.

Next, you will create a script code for performing create, store, update and delete products from the database table products using jQuery ajax request in laravel. So update this code in your list.blade.php file:

Next, navigate to resources/views and create image.blade.php file. Then update the following code into your image.blade.php file:

Step 8 – 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 –