PHP code example of ahmadhsalim / eloquent-filter-resolver
1. Go to this page and download the library: Download ahmadhsalim/eloquent-filter-resolver 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/ */
ahmadhsalim / eloquent-filter-resolver example snippets
use App\Http\Controllers\Controller;
use App\Models\User;
use Salim\FilterResolver\EloquentFilterResolver;
class UserController extends Controller
{
public function index()
{
$query = User::query();
$filter = 'contains(name, "john") and eq(status, active)';
EloquentFilterResolver::resolve($query, $filter);
return $query->paginate();
}
}
$filter = 'eq(name, "John") and (eq(status, "active") or eq(status, "inactive"))';
$filter = 'eq(user.role.name, "admin")';
$filter = 'eq(is_active, true) and eq(deleted_at, null)';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.