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(TwillModelContract $object, array $fields)

No description

array
getFormFieldsHandleRepeaters(TwillModelContract $object, array $fields)

No description

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

No description

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

No description

void
updateRepeaterWithPivot(TwillModelContract $object, array $fields, string $relation, array $pivotFields, string|null $modelOrRepository = null, string|null $repeaterName = null)

No description

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

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

array
getFormFieldForRepeaterWithPivot(TwillModelContract $object, array $fields, string $relation, array $pivotFields, ModuleRepository $modelOrRepository = null, string|null $repeaterName = null)

No description

array
getFormFieldsForRepeater(TwillModelContract $object, array $fields, string $relation, ModuleRepository $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 (should 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(TwillModelContract $object, array $fields)

No description

Parameters

TwillModelContract $object
array $fields

Return Value

void

array getFormFieldsHandleRepeaters(TwillModelContract $object, array $fields)

No description

Parameters

TwillModelContract $object
array $fields

Return Value

array

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

deprecated use updateRepeaterWithPivot

No description

Parameters

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

Return Value

void

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

No description

Parameters

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

Return Value

void

void updateRepeaterWithPivot(TwillModelContract $object, array $fields, string $relation, array $pivotFields, string|null $modelOrRepository = null, string|null $repeaterName = null)

No description

Parameters

TwillModelContract $object
array $fields
string $relation
array $pivotFields
string|null $modelOrRepository
string|null $repeaterName

Return Value

void

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

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

Parameters

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

Return Value

void

array getFormFieldForRepeaterWithPivot(TwillModelContract $object, array $fields, string $relation, array $pivotFields, ModuleRepository $modelOrRepository = null, string|null $repeaterName = null)

No description

Parameters

TwillModelContract $object
array $fields
string $relation
array $pivotFields
ModuleRepository $modelOrRepository
string|null $repeaterName

Return Value

array

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

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

Parameters

TwillModelContract $object
array $fields
string $relation
ModuleRepository $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 (should 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