src/QueryBuilder.php
public static function for($baseQuery, ?Request $request = null): self
    {
        if (is_string($baseQuery)) {
            $baseQuery = ($baseQuery)::query();
        }

        return new static($baseQuery, $request ?? request());
    }
public static function for($baseQuery, ?Request $request = null): self
    {
        if (is_string($baseQuery)) {
            $baseQuery = ($baseQuery)::query();
        }

        return new static($baseQuery, $request ?? request());
    }
public static function for ( $ baseQuery , ? Request $ request = null ) : self { if ( is_string ( $ baseQuery ) ) { $ baseQuery = ( $ baseQuery ) :: query ( ) ; } return new static ( $ baseQuery , $ request ?? request ( ) ) ; }
Create a new QueryBuilder for a request and model.

@param string|\Illuminate\Database\Query\Builder $baseQuery Model class or base query builder
@param \Illuminate\Http\Request                  $request

@return \Spatie\QueryBuilder\QueryBuilder
Create a new QueryBuilder for a request and model .