Today, We want to share with you Laravel 6 Ajax CRUD.In this post we will show you , hear for Laravel 6 – Create First Ajax CRUD Application from Scratch we will give you demo and example for implement.In this post, we will learn about AJAX CRUD Tutorial Using jQuery, JSON and Laravel 6 with an example.
Laravel 6 Ajax CRUD Example
There are the Following The simple About Laravel6 Ajax CRUD Full Information With Example and source code.
As I will cover this Post with live Working example to develop Ajax CRUD [CReate Update Delete] with PHP Laravel6, so the some major files and Directory structures for this example is following below.
Phase 1: Install Laravel 6
install fresh Laravel 6 version application
composer create-project --prefer-dist laravel/laravel socialapp
Phase 2: Install Yajra Datatable
composer require yajra/laravel-datatables-oracle
config/app.php
..... 'providers' => [ .... Yajra\DataTables\DataTablesServiceProvider::class, ] 'aliases' => [ .... 'DataTables' => Yajra\DataTables\Facades\DataTables::class, ] .....
Phase 3: Database Configuration
crud application of laravel 6
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=socialapp DB_USERNAME=root DB_PASSWORD=root
Phase 4: Create Migration Table
Laravel 6 php artisan command,
php artisan make:migration create_suggetions_table --create=suggetions
bigIncrements('id'); $table->string('name'); $table->text('detail'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('suggetions'); } }
php artisan migrate
Phase 5: Create Route
routes/web.php
Route::resource('ajaxsuggetions','SuggetionsAjaxController');
Phase 6: Add Controller and Model
app/Http/Controllers/SuggetionsAjaxController.php
ajax()) { $data = Suggetions::latest()->get(); return Datatables::of($data) ->addIndexColumn() ->addColumn('action', function($row){ $btn = 'Edit'; $btn = $btn.' Delete'; return $btn; }) ->rawColumns(['action']) ->make(true); } return view('suggetionAjax',compact('suggetions')); } public function store(Request $request) { Suggetions::updateOrCreate(['id' => $request->suggetion_id], ['name' => $request->name, 'detail' => $request->detail]); return response()->json(['success'=>'Suggetions saved successfully.']); } public function edit($id) { $suggetion = Suggetions::find($id); return response()->json($suggetion); } public function destroy($id) { Suggetions::find($id)->delete(); return response()->json(['success'=>'Suggetions deleted successfully.']); } }
app/Suggetions.php
Phase 7: Add Blade Files
resources/views/suggetionAjax.blade.php
Laravel6 Ajax CRUD tutorial using Datatable - pakainfo.com Simple Laravel 6 Ajax CRUD tutorial using Datatable - pakainfo.com
Create New Suggetions
No Name Details Action Download Laravel 6 Crud Source Code
Now We can test it by using simple following command:
php artisan serveNow We can open bellow URL on your browser:
http://localhost:8000/ajaxsuggetionsWeb Programming Tutorials Example with Demo
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about Laravel 6 Ajax CRUD Example Step By Step.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.