PHP code example of ymigval / laravel-model-datatable-ssp
1. Go to this page and download the library: Download ymigval/laravel-model-datatable-ssp library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ymigval / laravel-model-datatable-ssp example snippets
use App\Models\Customer;
return (new Customer())->datatable([
'first_name', 'last_name', 'phone'
]);
use App\Models\Customer;
return Customer::datatable([
'first_name', 'last_name', 'phone'
]);
use Illuminate\Support\Facades\DB;
return DB::table('customers')
->datatable([
'first_name',
'last_name',
'phone'
]);
use App\Models\Customer;
(new Customer())->datatable(
['first_name', 'last_name', 'phone'],
[],
'array'
);
use Illuminate\Support\Facades\DB;
DB::table('customers')->datatable(
['first_name', 'last_name', 'phone'],
[],
'json'
);
use App\Models\Customer;
return (new Customer())->datatable(
function () {
return ['first_name', 'last_name', 'phone'];
}
);
use App\Models\Customer;
return Customer::join('business', 'business.id_customer', '=', 'customers.id')
->datatable(
function () {
return ['customers.first_name', 'customers.last_name', 'business.name'];
}
);
use App\Models\Customer;
return Customer::join('business', 'business.id_customer', '=', 'customers.id')
->datatable(
[
'customers.first_name AS f_name',
'customers.last_name AS l_name',
'business.name AS aaa',
],
['customers.phone AS contact' => ['orderable' => false, 'searchable' => true]]
);
use App\Models\Customer;
return Customer::with('business')
->datatable(
[
'first_name',
'last_name',
function ($field, $row) {
return $row->business->name;
},
],
['id'] // 'id' is the localKey field specified in the relation with 'business'
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.