PHP code example of lykegenes / laravel-table-view
1. Go to this page and download the library: Download lykegenes/laravel-table-view 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/ */
lykegenes / laravel-table-view example snippets
'providers' => [
...
Lykegenes\TableView\Providers\TableViewServiceProvider::class,
],
namespace App\TableViews;
use Lykegenes\TableView\AbstractTableView;
class DemoTableView extends AbstractTableView
{
public function getApiUrl()
{
return '/demo-api';
}
public function build()
{
$this->addColumn('Nom', 'name', [
'sortable',
])
->addColumn('Adresse', 'address', [
'sortable',
])
->addColumn('Date', 'date', [
'sortable',
])
->addTemplateColumn('Tag', 'columns.locationTags')
->addTemplateColumn('Operation', 'columns.operations');
$this->setDefaultSort('date');
}
}
class ApiDemoController extends Controller
{
protected $users;
public function __construct(UserRepository $users)
{
$this->users = $users;
$this->users->setPresenter(UserPresenter::class);
}
public function demoApi(Request $request)
{
$sort = $request->input('sort', 'name');
$order = $request->input('order', 'asc');
$this->users->orderBy($sort, $order);
if ($request->has('search')) {
$this->users->pushCriteria(new \Lykegenes\TableView\Criteria\SearchCriteria(['name', 'email'], $request->input('search')));
}
return $this->users->paginate($request->input('limit', 15));
}
}