class UserRepository extends ModuleRepository (View source)

Traits

Mimic HandleBrowsers, but when the relation uses HasRelated instead of being a proper model relation.

Properties

protected array $browsers

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

from  HandleBrowsers
protected string|array|(array)|mix|(string|array)) $relatedBrowsers

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

from  HandleRelatedBrowsers
protected array $repeaters

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

from  HandleRepeaters
protected TwillModelContract $model from  ModuleRepository
protected string[] $ignoreFieldsBeforeSave from  ModuleRepository
protected array $countScope from  ModuleRepository
protected array $fieldsGroups from  ModuleRepository
bool $fieldsGroupsFormFieldNamesAutoPrefix from  ModuleRepository
string $fieldsGroupsFormFieldNameSeparator from  ModuleRepository
protected Repository $config
protected DatabaseManager $db
protected PasswordBrokerManager $passwordBrokerManager
protected Factory $authFactory

Methods

array
prepareFieldsBeforeCreateHandleDates(array $fields)

No description

array
prepareFieldsBeforeSaveHandleDates(TwillModelContract|null $object, array $fields)

No description

array
prepareDatesField(array $fields, string $field)

No description

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).

void
afterSaveHandleRelatedBrowsers(Model $object, array $fields)

No description

array
getFormFieldsHandleRelatedBrowsers(Model $object, array $fields)

No description

Collection
getRelatedBrowsers()

Get all related browser' detail info from the $relatedBrowsers attribute.

void
afterDuplicateHandleRelatedBrowsers(TwillModelContract $old, TwillModelContract $new)

Called from afterReplicate in ModuleRepository.

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).

hydrateHandleFieldsGroups(Model $object, array|null $fields)

No description

array
prepareFieldsBeforeSaveHandleFieldsGroups(Model|null $object, array $fields)

No description

array
prepareFieldsBeforeCreateHandleFieldsGroups(array $fields)

No description

array
getFormFieldsHandleFieldsGroups(Model $object, array $fields)

No description

handleFieldsGroups($fields)

No description

array
getModelCasts(Model $object)

No description

array
getFormFieldsHandlePermissions(TwillModelContract $object, array $fields)

Retrieve user-item permissions fields

afterSaveHandlePermissions(Model $object, array $fields)

Function executed after save on module form

Collection
get(array $with = [], array $scopes = [], array $orders = [], int $perPage = 20, bool $forcePagination = false, array $appliedFilters = [])

No description

int
getCountByStatusSlug(string $slug, array $scope = [])

No description

getById(int $id, array $with = [], array $withCount = [])

No description

Collection
listAll(string $column = 'title', array $orders = [], int|string|null $exceptId = null, string $pluckBy = 'id')

No description

Collection
cmsSearch(string $search, array $fields = [])

No description

firstOrCreate(array $attributes, array $fields = [])

No description

create(array $fields)

No description

createForPreview(array $fields)

No description

updateOrCreate(array $attributes, array $fields)

No description

update(int|string $id, array $fields)

No description

bool
updateBasic(int|string|null|array $id, array $values, array $scopes = [])

No description

void
setNewOrder(array $ids)

No description

TwillModelContract|null
duplicate(int|string $id, string $titleColumnKey = 'title')

No description

bool
delete(int|string $id)

No description

bool
bulkDelete(array $ids)

No description

bool
forceDelete(int|string $id)

No description

bool
bulkForceDelete(array $ids)

No description

bool
restore(int|string $id)

No description

bool
bulkRestore(array $ids)

No description

array
cleanupFields(TwillModelContract|null $object, array $fields)

No description

array
prepareFieldsBeforeCreate(array $fields)

No description

array
prepareFieldsBeforeSave(User $user, array $fields)

No description

void
afterUpdateBasic(User $user, array $fields)

No description

void
beforeSave(TwillModelContract $object, array $fields)

No description

void
afterSaveOriginalData(TwillModelContract $model, array $fields)

No description

void
afterSave(User $user, array $fields)

No description

void
afterDelete(TwillModelContract $object)

No description

void
afterRestore(TwillModelContract $object)

No description

hydrate(TwillModelContract $model, array $fields)

No description

array
getFormFields(User $user)

No description

Builder
filter(Builder $query, array $scopes = [])

No description

Builder
order(Builder $builder, array $orders = [])

No description

void
updateOneToMany(TwillModelContract $object, array $fields, string $relationship, string $formField, string $attribute)

No description

void
updateMultiSelect(TwillModelContract $object, array $fields, string $relationship)

No description

void
addRelationFilterScope(Builder $query, array $scopes, string $scopeField, string $scopeRelation)

No description

void
addLikeFilterScope(Builder $query, array $scopes, string $scopeField)

No description

bool
isUniqueFeature()

No description

void
addIgnoreFieldsBeforeSave(array $ignore = [])

No description

bool
shouldIgnoreFieldBeforeSave(string $ignore)

No description

array
getReservedFields()

No description

getModelRepository(string $relation, ModuleRepository|null $modelOrRepository = null)

No description

array
traitsMethods(string|null $method = null)

No description

string
getLikeOperator() deprecated

No description

mixed
__call(string $method, array $parameters)

No description

bool
hasBehavior(string $behavior)

No description

bool
isTranslatable($column)

No description

hydrateHandleMedias(Model $object, array $fields)

No description

void
afterSaveHandleMedias(Model $object, array $fields)

No description

array
getFormFieldsHandleMedias(Model $object, array $fields)

No description

array
getCrops(string $role)

No description

void
afterDuplicateHandleMedias(TwillModelContract $original, TwillModelContract $newObject)

No description

oauthUser(User $oauthUser)

No description

bool
oauthIsUserLinked(User $oauthUser, string $provider)

No description

oauthUpdateProvider(User $oauthUser, string $provider)

No description

oauthCreateUser(User $oauthUser)

No description

array
getFormFieldsHandleUserPermissions(Model|User $object, array $fields)

Retrieve user permissions fields.

afterSaveHandleUserPermissions(Model|User $object, array $fields)

Function executed after save on user form.

array
getUserPermissionsFields(Model|User $user, array $fields)

Get user permissions fields.

int|bool
getCountByStatusSlugHandleUserPermissions(string $slug, array $scope = [])

Retrieve count of user for 'activated' and 'pending' status slug.

__construct(DatabaseManager $db, Repository $config, PasswordBrokerManager $passwordBrokerManager, Factory $authFactory)

No description

Details

array prepareFieldsBeforeCreateHandleDates(array $fields)

No description

Parameters

array $fields

Return Value

array

array prepareFieldsBeforeSaveHandleDates(TwillModelContract|null $object, array $fields)

No description

Parameters

TwillModelContract|null $object
array $fields

Return Value

array

array prepareDatesField(array $fields, string $field)

No description

Parameters

array $fields
string $field

Return Value

array

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

void afterSaveHandleRelatedBrowsers(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

void

array getFormFieldsHandleRelatedBrowsers(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

array

protected Collection getRelatedBrowsers()

Get all related browser' detail info from the $relatedBrowsers attribute.

The missing information will be inferred by convention of Twill.

Return Value

Collection

void afterDuplicateHandleRelatedBrowsers(TwillModelContract $old, TwillModelContract $new)

Called from afterReplicate in ModuleRepository.

Parameters

TwillModelContract $old
TwillModelContract $new

Return Value

void

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

Model hydrateHandleFieldsGroups(Model $object, array|null $fields)

No description

Parameters

Model $object
array|null $fields

Return Value

Model

array prepareFieldsBeforeSaveHandleFieldsGroups(Model|null $object, array $fields)

No description

Parameters

Model|null $object
array $fields

Return Value

array

array prepareFieldsBeforeCreateHandleFieldsGroups(array $fields)

No description

Parameters

array $fields

Return Value

array

array getFormFieldsHandleFieldsGroups(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

array

protected handleFieldsGroups($fields)

No description

Parameters

$fields

protected array getModelCasts(Model $object)

No description

Parameters

Model $object

Return Value

array

array getFormFieldsHandlePermissions(TwillModelContract $object, array $fields)

Retrieve user-item permissions fields

Parameters

TwillModelContract $object
array $fields

Return Value

array

afterSaveHandlePermissions(Model $object, array $fields)

Function executed after save on module form

Parameters

Model $object
array $fields

Collection get(array $with = [], array $scopes = [], array $orders = [], int $perPage = 20, bool $forcePagination = false, array $appliedFilters = [])

No description

Parameters

array $with
array $scopes
array $orders
int $perPage
bool $forcePagination
array $appliedFilters

Return Value

Collection

int getCountByStatusSlug(string $slug, array $scope = [])

No description

Parameters

string $slug
array $scope

Return Value

int

TwillModelContract getById(int $id, array $with = [], array $withCount = [])

No description

Parameters

int $id
array $with
array $withCount

Return Value

TwillModelContract

Exceptions

ModelNotFoundException

Collection listAll(string $column = 'title', array $orders = [], int|string|null $exceptId = null, string $pluckBy = 'id')

No description

Parameters

string $column
array $orders
int|string|null $exceptId
string $pluckBy

Return Value

Collection

Collection cmsSearch(string $search, array $fields = [])

No description

Parameters

string $search
array $fields

Return Value

Collection

TwillModelContract firstOrCreate(array $attributes, array $fields = [])

No description

Parameters

array $attributes
array $fields

Return Value

TwillModelContract

TwillModelContract create(array $fields)

No description

Parameters

array $fields

Return Value

TwillModelContract

TwillModelContract createForPreview(array $fields)

No description

Parameters

array $fields

Return Value

TwillModelContract

TwillModelContract updateOrCreate(array $attributes, array $fields)

No description

Parameters

array $attributes
array $fields

Return Value

TwillModelContract

TwillModelContract update(int|string $id, array $fields)

No description

Parameters

int|string $id
array $fields

Return Value

TwillModelContract

bool updateBasic(int|string|null|array $id, array $values, array $scopes = [])

No description

Parameters

int|string|null|array $id
array $values
array $scopes

Return Value

bool

void setNewOrder(array $ids)

No description

Parameters

array $ids

Return Value

void

TwillModelContract|null duplicate(int|string $id, string $titleColumnKey = 'title')

No description

Parameters

int|string $id
string $titleColumnKey

Return Value

TwillModelContract|null

bool delete(int|string $id)

No description

Parameters

int|string $id

Return Value

bool

bool bulkDelete(array $ids)

No description

Parameters

array $ids

Return Value

bool

bool forceDelete(int|string $id)

No description

Parameters

int|string $id

Return Value

bool

bool bulkForceDelete(array $ids)

No description

Parameters

array $ids

Return Value

bool

bool restore(int|string $id)

No description

Parameters

int|string $id

Return Value

bool

bool bulkRestore(array $ids)

No description

Parameters

array $ids

Return Value

bool

array cleanupFields(TwillModelContract|null $object, array $fields)

No description

Parameters

TwillModelContract|null $object
array $fields

Return Value

array

array prepareFieldsBeforeCreate(array $fields)

No description

Parameters

array $fields

Return Value

array

array prepareFieldsBeforeSave(User $user, array $fields)

No description

Parameters

User $user
array $fields

Return Value

array

void afterUpdateBasic(User $user, array $fields)

No description

Parameters

User $user
array $fields

Return Value

void

void beforeSave(TwillModelContract $object, array $fields)

No description

Parameters

TwillModelContract $object
array $fields

Return Value

void

void afterSaveOriginalData(TwillModelContract $model, array $fields)

No description

Parameters

TwillModelContract $model
array $fields

Return Value

void

void afterSave(User $user, array $fields)

No description

Parameters

User $user
array $fields

Return Value

void

void afterDelete(TwillModelContract $object)

No description

Parameters

TwillModelContract $object

Return Value

void

void afterDuplicate(TwillModelContract $old, TwillModelContract $new)

No description

Parameters

TwillModelContract $old
TwillModelContract $new

Return Value

void

void afterRestore(TwillModelContract $object)

No description

Parameters

TwillModelContract $object

Return Value

void

TwillModelContract hydrate(TwillModelContract $model, array $fields)

No description

Parameters

TwillModelContract $model
array $fields

Return Value

TwillModelContract

array getFormFields(User $user)

No description

Parameters

User $user

Return Value

array

Builder filter(Builder $query, array $scopes = [])

No description

Parameters

Builder $query
array $scopes

Return Value

Builder

Builder order(Builder $builder, array $orders = [])

No description

Parameters

Builder $builder
array $orders

Return Value

Builder

void updateOneToMany(TwillModelContract $object, array $fields, string $relationship, string $formField, string $attribute)

No description

Parameters

TwillModelContract $object
array $fields
string $relationship
string $formField
string $attribute

Return Value

void

void updateMultiSelect(TwillModelContract $object, array $fields, string $relationship)

No description

Parameters

TwillModelContract $object
array $fields
string $relationship

Return Value

void

void addRelationFilterScope(Builder $query, array $scopes, string $scopeField, string $scopeRelation)

No description

Parameters

Builder $query
array $scopes
string $scopeField
string $scopeRelation

Return Value

void

void addLikeFilterScope(Builder $query, array $scopes, string $scopeField)

No description

Parameters

Builder $query
array $scopes
string $scopeField

Return Value

void

bool isUniqueFeature()

No description

Return Value

bool

void addIgnoreFieldsBeforeSave(array $ignore = [])

No description

Parameters

array $ignore

Return Value

void

bool shouldIgnoreFieldBeforeSave(string $ignore)

No description

Parameters

string $ignore

Return Value

bool

array getReservedFields()

No description

Return Value

array

protected ModuleRepository getModelRepository(string $relation, ModuleRepository|null $modelOrRepository = null)

No description

Parameters

string $relation
ModuleRepository|null $modelOrRepository

Return Value

ModuleRepository

protected array traitsMethods(string|null $method = null)

No description

Parameters

string|null $method

Return Value

array

protected string getLikeOperator() deprecated

deprecated use the helper getLikeOperator directly.

No description

Return Value

string

mixed __call(string $method, array $parameters)

No description

Parameters

string $method
array $parameters

Return Value

mixed

bool hasBehavior(string $behavior)

No description

Parameters

string $behavior

Return Value

bool

bool isTranslatable($column)

No description

Parameters

$column

Return Value

bool

TwillModelContract getBaseModel()

No description

Return Value

TwillModelContract

Model hydrateHandleMedias(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

Model

void afterSaveHandleMedias(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

void

array getFormFieldsHandleMedias(Model $object, array $fields)

No description

Parameters

Model $object
array $fields

Return Value

array

array getCrops(string $role)

No description

Parameters

string $role

Return Value

array

void afterDuplicateHandleMedias(TwillModelContract $original, TwillModelContract $newObject)

No description

Parameters

TwillModelContract $original
TwillModelContract $newObject

Return Value

void

User oauthUser(User $oauthUser)

No description

Parameters

User $oauthUser

Return Value

User

bool oauthIsUserLinked(User $oauthUser, string $provider)

No description

Parameters

User $oauthUser
string $provider

Return Value

bool

User oauthUpdateProvider(User $oauthUser, string $provider)

No description

Parameters

User $oauthUser
string $provider

Return Value

User

User oauthCreateUser(User $oauthUser)

No description

Parameters

User $oauthUser

Return Value

User

array getFormFieldsHandleUserPermissions(Model|User $object, array $fields)

Retrieve user permissions fields.

Parameters

Model|User $object
array $fields

Return Value

array

afterSaveHandleUserPermissions(Model|User $object, array $fields)

Function executed after save on user form.

Parameters

Model|User $object
array $fields

protected array getUserPermissionsFields(Model|User $user, array $fields)

Get user permissions fields.

Parameters

Model|User $user
array $fields

Return Value

array

int|bool getCountByStatusSlugHandleUserPermissions(string $slug, array $scope = [])

Retrieve count of user for 'activated' and 'pending' status slug.

Parameters

string $slug
array $scope

Return Value

int|bool

__construct(DatabaseManager $db, Repository $config, PasswordBrokerManager $passwordBrokerManager, Factory $authFactory)

No description

Parameters

DatabaseManager $db
Repository $config
PasswordBrokerManager $passwordBrokerManager
Factory $authFactory