How to Add Data in DataTable in Laravel Crud

In this tutorial I'm going to describe how to add data in DataTable in laravel 8 we will create single page companies ajax crud application (SPA) using dataTables js, modal and jQuery in laravel 8.

Step 1 — Download Laravel 8 App

1st step Install laravel project and new setup, lets open the terminal C:\xampp\htdocs and paste below code

Step 2 — Database Configuration

Setup database with your installed laravel 8 project . lets go to .env folder and put database name and connect to database.

Next run this command

Step 3 — Installing Yajra Datatables

Then configure datatables package. So go to config directory and open app.php file. And add the following service providers into app.php file:

Go to -> config/app.php and put in providers section

Then publish laravel datatables vendor package by using below command:

Step 4 — Make Model & Migration

Simply copy this code and paste in companies model

Lets migrate table to database run this command

After that, lets go to app/models directory and open company.php model file. Then add the following code into it:

Step 5 — Make Routes

Step 6 — Create AJAX CRUD Datatables Controller

Lets go to controller and copy below code and paste there

Step 6 — Create Blade Views File

Create two blade views file, which is following:

  • companies.blade.php

Next go to companies.blade.php file and paste below code

Lets go to your browser and run this url

Now its open like this and successfully working and store in database as well.

Thanks 🙏🙏

--

--

Hi I am Amit Experienced Web Developer with a demonstrated history of working in the information technology and services industry.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Amit Kumar

Hi I am Amit Experienced Web Developer with a demonstrated history of working in the information technology and services industry.