Laravel 7 Ajax CRUD using Datatables

Admin   Laravel   616  2021-03-17 20:10:04

Hi Guys

Today, i will let you know example of laravel 7 yajra datatable crud example. let’s discuss about ajax crud operations in laravel 7 with modal & pagination. i would like to share with you laravel 7 ajax crud example. We will use laravel 7 datatable ajax crud.

In this tutorial,I will show the ajax crud in laravel 7.we will explain ajax crud in laravel 7 . we will simply write jquery ajax request for crud with yajra datatable laravel 7. i will guide you step by step ajax crud operations in laravel 7 with modal & pagination. we will create jquery ajax crud with modals using datatables js in laravel 7.

We will use bootstrap modal for create new records and update new records. we will use resource routes to create crud (create read update delete) application in laravel 7.We will use yajra datatable to list a records with pagination, sorting and filter.

Preview

List Page

Create Page

Edit Page

Here following step of ajax crud laravel 7

Step 1 : Install Laravel 7 Application

we are going from scratch, So we require to get fresh Laravel application using bellow command, So open your terminal OR command prompt and run bellow command:

 

composer create-project --prefer-dist laravel/laravel blog

Database Configuration

In this step, we require to make database configuration, you have to add following details on your .env file.

1.Database Username

1.Database Password

1.Database Name

In .env file also available host and port details, you can configure all details as in your system, So you can put like as bellow:

following path: .env

 

DB_HOST=localhost

DB_DATABASE=homestead

DB_USERNAME=homestead

DB_PASSWORD=secret

Step :2 Install Yajra Datatable

in this step, We need to install yajra datatable composer package for datatable, so you can install using following command:

 

composer require yajra/laravel-datatables-oracle

Next that you need to set providers and alias.

following path: config/app.php

 

.....

'providers' => [

....

Yajra\DataTables\DataTablesServiceProvider::class,

]

'aliases' => [

....

'DataTables' => Yajra\DataTables\Facades\DataTables::class,

]

.....

Step 3: Create items Table and Model

In this step we have to create migration for items table using Laravel 7 php artisan command, so first fire bellow command:

 

php artisan make:model Item -m

After this command you have to put bellow code in your migration file for create items table.

following path: /database/migrations/2020_02_03_102325_create_items_table.php