PHP code example of catlabinteractive / laravel-table
1. Go to this page and download the library: Download catlabinteractive/laravel-table 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/ */
catlabinteractive / laravel-table example snippets
use CatLab\Laravel\Table\Table;
$table = (new Table($collection, $resourceDefinition, $context, $request->getRequestUri()))
->sortable() // headers of ->sortable() fields link to ?sort=field / ?sort=!field
->filterable() // a GET form with one input per ->filterable() field (select for enums)
->setResourceUrlResolver(function (RESTResource $related) {
return '/admin/things/' . $related->getIdentifiers()->getValues()[0]->getValue(); // null suppresses the link
})
->setResourceLabelResolver(function (RESTResource $related) {
return $related->toArray()['uid'] ?? null; // null falls back to the default heuristic
})
->modelAction(...)
->collectionAction(...);
echo $table->render();