PHP code example of mrjj / lvlgrid
1. Go to this page and download the library: Download mrjj/lvlgrid 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/ */
mrjj / lvlgrid example snippets
'providers' => [
Mrjj\LvlGrid\LvlGridServiceProvider::class
];
Route::get('countries/grid', '....Controller@grid');
use Mrjj\LvlGrid\LvlGrid;
class ..Controller extends Controller
{
use LvlGrid
protected $gridModel = \App\Models\Country::class;
protected $threshold = 30;
...
}
@extend('default')
@section('scripts')
@>
@data="items"
:columns="[{
'key': 'name',
'name': 'Name'
},{
'key': 'monetary',
'name': 'Monetary unit'
}]"
:routes="{
function: '/countries/grid',
edit: {
column: 'id',
name: '/countries/:column/edit'
},
delete: {
column: 'id',
name: '/countries/:column/delete'
}
}">
</lvlgrid>
</div>
..
public function gridData()
{
return DB::table('users')
->leftJoin('posts', 'users.id', '=', 'posts.user_id')
}
public function gridTransformer($data)
{
foreach($data['items'] as $_grid) {
$_grid->status = trans('form.status.'.$_grid->status);
}
}
bash
php artisan vendor:publish --provider="Mrjj\LvlGrid\LvlGridServiceProvider"