PHP code example of fugazi-code / laravel-eloquent-filter
1. Go to this page and download the library: Download fugazi-code/laravel-eloquent-filter 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/ */
fugazi-code / laravel-eloquent-filter example snippets
php
namespace App\Http\Controllers\Filters;
use FugaziCode\Filter\Filter;
class UserFilter extends Filter
{
public function email($value)
{
$this->query->where('email', 'like', "%$value%");
}
public function permanent($value)
{
$this->query->whereHas('address', function($query) use ($value) {
$query->where('permanent', 'like', "%$value%");
});
}
}
php
Route::get('/', function () {
return User::query()->with(['address'])->filter(new UserFilter)->get();
});