trait HandleRepeaters (View source)

Properties

protected array $repeaters

All repeaters used in the model, as an array of repeater names: [ 'article_repeater', 'page_repeater' ].

Methods

void
afterSaveHandleRepeaters(Model $object, array $fields)

No description

array
getFormFieldsHandleRepeaters(Model $object, array $fields)

No description

void
updateRepeaterMany(Model $object, array $fields, string $relation, bool $keepExisting = true, Model|null $model = null)

No description

void
updateRepeaterMorphMany(Model $object, array $fields, string $relation, string|null $morph = null, Model|null $model = null, string|null $repeaterName = null)

No description

void
updateRepeater(Model $object, array $fields, string $relation, Model|ModuleRepository|null $modelOrRepository = null, string|null $repeaterName = null)

Given relation, model and repeaterName, retrieve the repeater data from request and update the database record.

array
getFormFieldsForRepeater(Model $object, array $fields, string $relation, Model|ModuleRepository|null $modelOrRepository = null, string|null $repeaterName = null)

Given relation, model and repeaterName, get the necessary fields for rendering a repeater.

Collection
getRepeaters()

Get all repeaters' model and relation from the $repeaters attribute.

string
inferRelationFromRepeaterName(string $repeaterName)

Guess the relation name (shoud be lower camel case, ex. userGroup, contactOffice).

string
inferModelFromRepeaterName(string $repeaterName)

Guess the model name (should be singular upper camel case, ex. User, ArticleType).

Details

void afterSaveHandleRepeaters(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

void

array getFormFieldsHandleRepeaters(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

array

void updateRepeaterMany(Model $object, array $fields, string $relation, bool $keepExisting = true, Model|null $model = null)

No description

Parameters

Model $object
array $fields
string $relation
bool $keepExisting
Model|null $model

Return Value

void

void updateRepeaterMorphMany(Model $object, array $fields, string $relation, string|null $morph = null, Model|null $model = null, string|null $repeaterName = null)

No description

Parameters

Model $object
array $fields
string $relation
string|null $morph
Model|null $model
string|null $repeaterName

Return Value

void

void updateRepeater(Model $object, array $fields, string $relation, Model|ModuleRepository|null $modelOrRepository = null, string|null $repeaterName = null)

Given relation, model and repeaterName, retrieve the repeater data from request and update the database record.

Parameters

Model $object
array $fields
string $relation
Model|ModuleRepository|null $modelOrRepository
string|null $repeaterName

Return Value

void

array getFormFieldsForRepeater(Model $object, array $fields, string $relation, Model|ModuleRepository|null $modelOrRepository = null, string|null $repeaterName = null)

Given relation, model and repeaterName, get the necessary fields for rendering a repeater.

Parameters

Model $object
array $fields
string $relation
Model|ModuleRepository|null $modelOrRepository
string|null $repeaterName

Return Value

array

protected Collection getRepeaters()

Get all repeaters' model and relation from the $repeaters attribute.

The missing information will be inferred by convention of Twill.

Return Value

Collection

protected string inferRelationFromRepeaterName(string $repeaterName)

Guess the relation name (shoud be lower camel case, ex. userGroup, contactOffice).

Parameters

string $repeaterName

Return Value

string

protected string inferModelFromRepeaterName(string $repeaterName)

Guess the model name (should be singular upper camel case, ex. User, ArticleType).

Parameters

string $repeaterName

Return Value

string