1. Go to this page and download the library: Download aedart/athenaeum-filters 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/ */
aedart / athenaeum-filters example snippets
namespace Acme\Filters;
use Aedart\Filters\BaseBuilder;
use Acme\Filters\Processors\MySearchProcessor;
use Acme\Filters\Processors\TextProcessor;
use Acme\Filters\Processors\DateProcessor;
use Acme\Filters\Processors\SortProcessor;
class UserFilterBuilder extends BaseBuilder
{
public function processors(): array
{
// Key = http query parameter, value = parameter processor...
return [
'search' => MySearchProcessor::make(),
'name' => TextProcessor::make(),
'created_at' => DateProcessor::make(),
'sort' => SortProcessor::make()
->force(),
// ...etc
];
}
}
namespace Acme\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Aedart\Contracts\Filters\BuiltFiltersMap;
use Acme\Filters\UserFilterBuilder;
class ListUsersRequest exends FormRequest
{
public ?BuiltFiltersMap $filters = null;
public function after(Validator $validator)
{
// Add filters using your custom builder
$this->filters = UserFilterBuilder::make($this)
->build();
}
// ... remaining not shown ...
}
use App\Http\Controllers\Controller;
use App\Models\User;
use Acme\Requests\ListUsersRequest;
class UsersController extends Controller
{
public function index(ListUsersRequest $request)
{
// Apply all requested filters...
return User::applyFilters($request->filters->all())
->paginate(10);
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.