class Model

Properties

protected Model $model

Eloquent model instance of the grid model.

protected Model $originalModel
protected Collection $queries

Array of queries of the eloquent model.

protected array $sort

Sort parameters of the model.

protected array $data
protected $perPage
protected bool $usePaginate

If the model use pagination.

protected string $perPageName

The query string variable used to store the per-page.

protected string $sortName

The query string variable used to store the sort.

protected Closure $collectionCallback

Collection callback.

protected Grid $grid
protected Relation $relation
protected array $eagerLoads

Methods

__construct(Model $model, Grid $grid = null)

Create a new grid model instance.

Model
getOriginalModel()

No description

Model
eloquent()

Get the eloquent model of the grid model.

usePaginate(bool $use = true)

Enable or disable pagination.

string
getPerPageName()

Get the query string variable used to store the per-page.

$this
setPerPageName(string $name)

Set the query string variable used to store the per-page.

int
getPerPage()

Get per-page number.

$this
setPerPage(int $perPage)

Set per-page number.

string
getSortName()

Get the query string variable used to store the sort.

$this
setSortName(string $name)

Set the query string variable used to store the sort.

getGrid()

Get parent gird instance.

$this
setGrid(Grid $grid)

Set parent grid instance.

Relation
getRelation()

No description

$this
setRelation(Relation $relation)

No description

array|bool
getConstraints()

Get constraints.

$this
collection(Closure $callback = null)

Set collection callback.

array|Collection|mixed
buildData(bool $toArray = true)

Build.

bool
chunk(callable $callback, int $count = 100)

No description

$this
addConditions(array $conditions)

Add conditions to grid model.

string
getTable()

Get table of the model.

Builder|Model
getQueryBuilder()

No description

void
resetOrderBy()

Reset orderBy query.

$this
__call(string $method, array $arguments)

No description

bool
edit(mixed $id, string $field, string $value)

No description

$this|Model
with(mixed $relations)

Set the relationships that should be eager loaded.

mixed
__get($key)

No description

Collection
get()

No description

void
handleInvalidPage(LengthAwarePaginator $paginator)

If current page is greater than last page, then redirect to last page.

void
setPaginate()

Set the grid paginate.

array
resolvePerPage(array|null $paginate)

Resolve perPage for pagination.

findQueryByMethod($method)

Find query by method name.

void
setSort()

Set the grid sort.

void
setRelationSort(string $column)

Set relation sort.

array
joinParameters(Relation $relation)

Build join parameters for related model.

static void
doNotSnakeAttributes(Model $model)

Don't snake case attributes.

Details

at line 110
__construct(Model $model, Grid $grid = null)

Create a new grid model instance.

Parameters

Model $model
Grid $grid

at line 126
Model getOriginalModel()

No description

Return Value

Model

at line 136
Model eloquent()

Get the eloquent model of the grid model.

Return Value

Model

at line 146
usePaginate(bool $use = true)

Enable or disable pagination.

Parameters

bool $use

at line 156
string getPerPageName()

Get the query string variable used to store the per-page.

Return Value

string

at line 168
$this setPerPageName(string $name)

Set the query string variable used to store the per-page.

Parameters

string $name

Return Value

$this

at line 180
int getPerPage()

Get per-page number.

Return Value

int

at line 192
$this setPerPage(int $perPage)

Set per-page number.

Parameters

int $perPage

Return Value

$this

at line 206
string getSortName()

Get the query string variable used to store the sort.

Return Value

string

at line 218
$this setSortName(string $name)

Set the query string variable used to store the sort.

Parameters

string $name

Return Value

$this

at line 230
Grid getGrid()

Get parent gird instance.

Return Value

Grid

at line 242
$this setGrid(Grid $grid)

Set parent grid instance.

Parameters

Grid $grid

Return Value

$this

at line 252
Relation getRelation()

No description

Return Value

Relation

at line 262
$this setRelation(Relation $relation)

No description

Parameters

Relation $relation

Return Value

$this

at line 274
array|bool getConstraints()

Get constraints.

Return Value

array|bool

at line 292
$this collection(Closure $callback = null)

Set collection callback.

Parameters

Closure $callback

Return Value

$this

at line 306
array|Collection|mixed buildData(bool $toArray = true)

Build.

Parameters

bool $toArray

Return Value

array|Collection|mixed

at line 332
bool chunk(callable $callback, int $count = 100)

No description

Parameters

callable $callback
int $count

Return Value

bool

at line 356
$this addConditions(array $conditions)

Add conditions to grid model.

Parameters

array $conditions

Return Value

$this

at line 370
string getTable()

Get table of the model.

Return Value

string

at line 378
Builder|Model getQueryBuilder()

No description

Return Value

Builder|Model

at line 402
void resetOrderBy()

Reset orderBy query.

Return Value

void

at line 415
$this __call(string $method, array $arguments)

No description

Parameters

string $method
array $arguments

Return Value

$this

at line 432
bool edit(mixed $id, string $field, string $value)

No description

Parameters

mixed $id
string $field
string $value

Return Value

bool

at line 451
$this|Model with(mixed $relations)

Set the relationships that should be eager loaded.

Parameters

mixed $relations

Return Value

$this|Model

at line 485
mixed __get($key)

No description

Parameters

$key

Return Value

mixed

at line 499
protected Collection get()

No description

Return Value

Collection

Exceptions

Exception

at line 536
protected void handleInvalidPage(LengthAwarePaginator $paginator)

If current page is greater than last page, then redirect to last page.

Parameters

LengthAwarePaginator $paginator

Return Value

void

at line 551
protected void setPaginate()

Set the grid paginate.

Return Value

void

at line 582
protected array resolvePerPage(array|null $paginate)

Resolve perPage for pagination.

Parameters

array|null $paginate

Return Value

array

at line 612
protected Model findQueryByMethod($method)

Find query by method name.

Parameters

$method

Return Value

Model

at line 624
protected void setSort()

Set the grid sort.

Return Value

void

at line 667
protected void setRelationSort(string $column)

Set relation sort.

Parameters

string $column

Return Value

void

at line 709
protected array joinParameters(Relation $relation)

Build join parameters for related model.

HasOne and BelongsTo relation has different join parameters.

Parameters

Relation $relation

Return Value

array

Exceptions

Exception

at line 743
static protected void doNotSnakeAttributes(Model $model)

Don't snake case attributes.

Parameters

Model $model

Return Value

void