trait HandleBrowsers (View source)

Properties

protected array $browsers

All browsers used in the model, as an array of browser names: [ 'books', 'publications' ].

Methods

void
afterSaveHandleBrowsers(Model $object, array $fields)

No description

array
getFormFieldsHandleBrowsers(Model $object, array $fields)

No description

void
updateBrowser(TwillModelContract $object, array $fields, string $relationship, string $positionAttribute = 'position', string|null $browserName = null, array $pivotAttributes = [])

No description

void
updateOrderedBelongsTomany(Model $object, array $fields, string $relationship, string $positionAttribute = 'position')

No description

void
updateRelatedBrowser(Model $object, array $fields, string $browserName)

No description

array
getFormFieldsForBrowser(TwillModelContract $object, string $relation, string|null $routePrefix = null, string $titleKey = 'title', string|null $moduleName = null)

No description

array
getFormFieldsForRelatedBrowser(Model $object, string $relation, $titleKey = 'title')

No description

Collection
getBrowsers()

Get all browser' detail info from the $browsers attribute.

string
inferRelationFromBrowserName(string $browserName)

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

string
inferModelFromModuleName(string $moduleName)

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

string
inferModuleNameFromBrowserName(string $browserName)

Guess the browser's module name (should be plural lower camel case, ex. userGroups, contactOffices).

Details

void afterSaveHandleBrowsers(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

void

array getFormFieldsHandleBrowsers(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

array

void updateBrowser(TwillModelContract $object, array $fields, string $relationship, string $positionAttribute = 'position', string|null $browserName = null, array $pivotAttributes = [])

No description

Parameters

TwillModelContract $object
array $fields
string $relationship
string $positionAttribute
string|null $browserName
array $pivotAttributes

Return Value

void

void updateOrderedBelongsTomany(Model $object, array $fields, string $relationship, string $positionAttribute = 'position')

No description

Parameters

Model $object
array $fields
string $relationship
string $positionAttribute

Return Value

void

void updateRelatedBrowser(Model $object, array $fields, string $browserName)

No description

Parameters

Model $object
array $fields
string $browserName

Return Value

void

array getFormFieldsForBrowser(TwillModelContract $object, string $relation, string|null $routePrefix = null, string $titleKey = 'title', string|null $moduleName = null)

No description

Parameters

TwillModelContract $object
string $relation
string|null $routePrefix
string $titleKey
string|null $moduleName

Return Value

array

array getFormFieldsForRelatedBrowser(Model $object, string $relation, $titleKey = 'title')

No description

Parameters

Model $object
string $relation
$titleKey

Return Value

array

protected Collection getBrowsers()

Get all browser' detail info from the $browsers attribute.

The missing information will be inferred by convention of Twill.

Return Value

Collection

protected string inferRelationFromBrowserName(string $browserName)

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

Parameters

string $browserName

Return Value

string

protected string inferModelFromModuleName(string $moduleName)

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

Parameters

string $moduleName

Return Value

string

protected string inferModuleNameFromBrowserName(string $browserName)

Guess the browser's module name (should be plural lower camel case, ex. userGroups, contactOffices).

Parameters

string $browserName

Return Value

string