PHP code example of elfstack / slim-listing
1. Go to this page and download the library: Download elfstack/slim-listing 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/ */
elfstack / slim-listing example snippets
$config = [
'settings' => [
'displayErrorDetails' => true,
'db' => [
'driver' => 'sqlite',
'database' => __DIR__.'/../database.sqlite'
]
],
];
$app = new \Slim\App($config);
$container = $app->getContainer();
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($container['settings']['db']);
$capsule->bootEloquent();
$capsule->setAsGlobal();
$container['db'] = function ($container) use ($capsule){
return $capsule;
};
function controllerMethod(Request $request, Response $response)
{
return Listing::create(new Model())
->attachSearching(['field1', 'field2'])
->attachSorting(['field1', 'field2'])
->attachFiltering(['field1', 'field2'])
->modifyQuery(function ($query) {
$query->with('model2');
})
->get($request, $response);
}
Listing::create(Model::class);
Listing::create(new Model());
get($request);
get($request, $response);