In this Tutorial,I will learn you how to ue datatable dropdown search in laravel.You can easy and simple use datatable dropdown filter in laravel.
We would love to share with you how to add custom date filter and custom input search field and without display data without page refresh on datatables.
Laravel yajra datatables provide default global search, in that search it will search entire row of table. But if you need to add for only one specific column like for created date search with datepicker or status with dropdown then you must have to implement custom filtering in your datatable.
Step 1: Install Laravel 7
In this step,you can install laravel 7 application. So run bellow command and get clean fresh laravel 7 application.
composer create-project --prefer-dist laravel/laravel blog
Step 2: Install Yajra Datatable
We need to install yajra datatable package.so you can install using following command:
composer require yajra/laravel-datatables-oracle
After that you need to set providers and alias.
'providers' => [
'aliases' => [
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
Step 3: Add Dummy Records
we will create some dummy users using tinker factory. so let's create dummy records using bellow command:
php artisan tinker
Step 4: Add Route
In this step,you can create route for datatale layout file data.
Route::get('users', ['uses'=>'[email protected]', 'as'=>'users.index']);
Step 5: Create Controller
In this step,you can create to usercontroller.this controller mange to getting data and layout for datatable.