This is the documentation for
v4 but the latest version is
v5
.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/laravel-query-builder
As the QueryBuilder
extends Laravel's default Eloquent query builder you can use any method or macro you like. You can also specify a base query instead of the model FQCN:
QueryBuilder::for(User::where('id', 42)) // base query instead of model
->allowedIncludes(['posts'])
->where('activated', true) // chain on any of Laravel's query methods
->first(); // we only need one specific user