User
Administrator user model
class Backend\Models\User
extends Winter\Storm\Auth\Models\User
implements
Illuminate\Contracts\Auth\Authenticatable,
Winter\Storm\Database\ModelInterface
Traits
Trait | Description |
---|---|
DeferredBinding
|
|
Emitter
|
Adds event related features to any class. |
ExtendableTrait
|
This extension trait is used when access to the underlying base class is not available, such as classes that belong to the foundation framework (Laravel). It is currently used by the Controller and Model classes. |
GuardsAttributes
|
|
HasRelationships
|
|
Hashable
|
|
HidesAttributes
|
Hides and shows attributes for serialization. |
Purgeable
|
|
SoftDelete
|
|
Validation
|
Properties
public
$attachOne
:
mixed
= {"avatar":{}}
public
$belongsTo
:
mixed
= {"role":{}}
public
$belongsToMany
:
mixed
= {"groups":{"0":{},"table":"backend_users_groups"}}
Relations
public
static
$loginAttribute
:
string
= "login"
Login attribute
public
$rules
:
mixed
= {"email":"required|between:6,255|email|unique:backend_users","login":"required|between:2,255|unique:backend_users","password":"required:create|min:4|confirmed","password_confirmation":"required_with:password|min:4"}
Validation rules
protected
$dates
:
array
= ["activated_at","last_login","created_at","updated_at","deleted_at"]
Attributes that should be cast to dates
protected
$jsonable
:
array
= ["permissions","metadata"]
List of attribute names which are json encoded and decoded from the database.
protected
$purgeable
:
mixed
= ["password_confirmation","send_invite"]
Purge attributes from data set.
protected
$table
:
string
= "backend_users"
The database table used by the model.
public
$attachMany
:
mixed
= []
protected $attachMany = [ 'pictures' => ['Winter\Storm\Database\Attach\File', 'name'=> 'imageable'] ];
public
$attributeNames
:
array
= []
The array of custom attribute names.
public
$attributes
:
array
= []
Make the model's attributes public so behaviors can modify them.
public
$customMessages
:
array
= []
The array of custom error messages.
public
$duplicateCache
:
bool
= true
Indicates if duplicate queries from this model should be cached in memory.
public
$hasMany
:
array
= []
Cleaner declaration of relationships.
Uses a similar approach to the relation methods used by Eloquent, but as separate properties that make the class file less cluttered.
It should be declared with keys as the relation name, and value being a mixed array. The relation type $morphTo does not include a classname as the first value.
Example: class Order extends Model { protected $hasMany = [ 'items' => 'Item' ]; }
public
$hasManyThrough
:
mixed
= []
protected $hasManyThrough = [ 'posts' => ['Posts', 'through' => 'User'] ];
public
$hasOne
:
mixed
= []
protected $hasOne = [ 'owner' => ['User', 'key' => 'user_id'] ];
public
$hasOneThrough
:
mixed
= []
protected $hasOneThrough = [ 'post' => ['Posts', 'through' => 'User'] ];
public
$implement
:
string
|
array
|
null
= null
Extensions implemented by this class.
public
$morphMany
:
mixed
= []
protected $morphMany = [ 'log' => ['History', 'name' => 'user'] ];
public
$morphOne
:
mixed
= []
protected $morphOne = [ 'log' => ['History', 'name' => 'user'] ];
public
$morphTo
:
mixed
= []
protected $morphTo = [ 'pictures' => [] ];
public
$morphToMany
:
mixed
= []
protected $morphToMany = [ 'tag' => ['Tag', 'table' => 'tagables', 'name' => 'tagable'] ];
public
$morphedByMany
:
mixed
= []
public $sessionKey : string
A unique session key used for deferred binding.
public
$trimStringAttributes
:
bool
= true
Indicates if all string model attributes will be trimmed prior to saving.
protected
$allowedPermissionsValues
:
array
= [-1,0,1]
Allowed permissions values.
Possible options: -1 => Deny (adds to array, but denies regardless of user's group). 0 => Remove. 1 => Add.
protected
$emitterEventCollection
:
array
= []
Collection of registered events.
protected
$emitterEventSorted
:
array
= []
Sorted collection of events.
protected
$emitterSingleEventCollection
:
array
= []
Collection of registered events to be fired once only.
protected
static
$eventsBooted
:
array
= []
The array of models booted events.
protected
static
$extendableCallbacks
:
array
= []
Used to extend the constructor of an extendable class. Eg:
Class::extend(function($obj) { })
protected
static
$extendableClassLoader
:
ClassLoader
|
null
= null
Class loader instance.
protected
static
$extendableGuardProperties
:
bool
= true
Indicates if dynamic properties can be created.
protected
static
$extendableStaticMethods
:
array
= []
Collection of static methods used by behaviors.
protected
$extensionData
:
array
= {"extensions":[],"methods":[],"dynamicMethods":[],"dynamicProperties":[]}
Class reflection information, including behaviors.
protected
$forceDeleting
:
bool
= false
Indicates if the model is currently force deleting.
protected
$guarded
:
string[]
|
bool
= ["is_superuser","reset_password_code","activation_code","persist_code","role_id"]
The attributes that aren't mass assignable.
protected
$hashable
:
array
= ["password","persist_code"]
List of attribute names which should be hashed using the Bcrypt hashing algorithm.
protected
$hidden
:
array<int,string>
= ["password","reset_password_code","activation_code","persist_code"]
The attributes that should be hidden for arrays.
protected $mergedPermissions : array
The user merged permissions.
protected
$originalHashableValues
:
array
= []
List of original attribute values before they were hashed.
protected
$originalPurgeableValues
:
array
= []
List of original attribute values before they were purged.
protected
static
$relationTypes
:
array
= ["hasOne","hasMany","belongsTo","belongsToMany","morphTo","morphOne","morphMany","morphToMany","morphedByMany","attachOne","attachMany","hasOneThrough","hasManyThrough"]
Excepted relationship types, used to cycle and verify relationships.
protected
$rememberTokenName
:
string
= "persist_code"
The column name of the "remember me" token.
protected
$validationDefaultAttrNames
:
array
= []
Default custom attribute names.
protected $validationErrors : Illuminate\Support\MessageBag
The message bag instance containing validation error messages
Methods
public afterCreate () : void
After create event
public afterLogin () : void
After login event
public
canBeImpersonated (boolean $impersonator = false
)
: bool
Check if this user can be impersonated by the provided impersonator
Super users cannot be impersonated and all users cannot be impersonated unless there is an impersonator
present and the impersonator has access to backend.impersonate_users
, and the impersonator is not the
user being impersonated
Property | Type | Description |
---|---|---|
$impersonator | boolean |
boolean
The user attempting to impersonate this user, false when not available |
public
getAvatarThumb (integer $size = 25
, $options = null
)
Returns the public image file path to this user's avatar.
Property | Type | Description |
---|---|---|
$size | integer |
integer
|
$options | mixed |
mixed
|
public getFullNameAttribute () : string
Returns the user's full name.
public getGroupsOptions ()
public getMergedPermissions () : array
Returns an array of merged permissions based on the user's individual permissions and their group permissions filtering out any permissions the impersonator doesn't have access to (if the current user is being impersonated)
public getPersistCode () : string
Gets a code for when the user is persisted to a cookie or session which identifies the user.
public getRoleOptions ()
public isSuspended () : bool
Check if the user is suspended.
public sendInvitation () : void
Sends an invitation to the user using template "backend::mail.invite".
public unsuspend () : void
Remove the suspension on this user.
public __call ($name, $params)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$params | mixed |
mixed
|
public static __callStatic ($name, $params)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$params | mixed |
mixed
|
public
__construct (array $attributes = []
)
Constructor
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
public __get ($name)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
public __isset (string $key) : bool
Determine if an attribute or relation exists on the model.
Property | Type | Description |
---|---|---|
$key | string |
string
|
public __set ($name, $value)
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$value | mixed |
mixed
|
public addAttachManyRelation (string $name, array $config) : void
Dynamically add an AttachMany relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addAttachOneRelation (string $name, array $config) : void
Dynamically add an AttachOne relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addBelongsToManyRelation (string $name, array $config) : void
Dynamically add a BelongsToMany relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addBelongsToRelation (string $name, array $config) : void
Dynamically add a BelongsTo relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addCasts (array $attributes) : void
Add attribute casts for the model.
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
public addDateAttribute (string $attribute) : void
Adds a datetime attribute to convert to an instance of Carbon/DateTime object.
Property | Type | Description |
---|---|---|
$attribute | string |
string
|
public
addDynamicMethod (string $dynamicName, callable $method, string $extension = null
)
Programmatically adds a method to the extendable class
Property | Type | Description |
---|---|---|
$dynamicName | string |
string
|
$method | callable |
callable
|
$extension | string |
string
|
public
addDynamicProperty (string $dynamicName, mixed $value = null
)
: void
Programmatically adds a property to the extendable class
Property | Type | Description |
---|---|---|
$dynamicName | string |
string
The name of the property to add |
$value | mixed |
mixed
The value of the property |
public
addFillable (array | string | null $attributes = null
)
: void
Add fillable attributes for the model.
Property | Type | Description |
---|---|---|
$attributes | array | string | null |
array | string | null
|
public addGroup (Group $group) : bool
Adds the user to the given group.
Property | Type | Description |
---|---|---|
$group | Group |
Group
|
public addHasManyRelation (string $name, array $config) : void
Dynamically add a HasMany relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addHasManyThroughRelation (string $name, array $config) : void
Dynamically add a(n) HasManyThrough relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addHasOneRelation (string $name, array $config) : void
Dynamically add a HasOne relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addHasOneThroughRelation (string $name, array $config) : void
Dynamically add a(n) HasOneThrough relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public
addHashable (array | string | null $attributes = null
)
: $this
Adds an attribute to the hashable attributes list
Property | Type | Description |
---|---|---|
$attributes | array | string | null |
array | string | null
|
public addHashableAttribute ($attribute)
Property | Type | Description |
---|---|---|
$attribute | mixed |
mixed
|
public
addHidden (array | string | null $attributes = null
)
: void
Add hidden attributes for the model.
This restores the addHidden
method that was removed from Laravel 7 onwards. It is however recommended to use
the makeHidden
method going forward.
Property | Type | Description |
---|---|---|
$attributes | array | string | null |
array | string | null
|
public
addJsonable (array | string | null $attributes = null
)
: void
Add jsonable attributes for the model.
Property | Type | Description |
---|---|---|
$attributes | array | string | null |
array | string | null
|
public addMorphManyRelation (string $name, array $config) : void
Dynamically add a MorphMany relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addMorphOneRelation (string $name, array $config) : void
Dynamically add a MorphOne relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addMorphToManyRelation (string $name, array $config) : void
Dynamically add a MorphToMany relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addMorphToRelation (string $name, array $config) : void
Dynamically add a MorphTo relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public addMorphedByManyRelation (string $name, array $config) : void
Dynamically add a MorphedByMany relationship
Property | Type | Description |
---|---|---|
$name | string |
string
|
$config | array |
array
|
public
addPurgeable (array | string | null $attributes = null
)
: $this
Adds an attribute to the purgeable attributes list
Property | Type | Description |
---|---|---|
$attributes | array | string | null |
array | string | null
|
public
addVisible (array | string | null $attributes = null
)
: void
Add visible attributes for the model.
This restores the addVisible
method that was removed from Laravel 7 onwards. It is however recommended to use
the makeVisible
method going forward.
Property | Type | Description |
---|---|---|
$attributes | array | string | null |
array | string | null
|
public afterDelete () : void
Delete the user groups
public
alwaysPush (array $options = []
, string | null $sessionKey = null
)
: bool
Pushes the first level of relations even if the parent model has no changes.
Property | Type | Description |
---|---|---|
$options | array |
array
|
$sessionKey | string | null |
string | null
|
public asExtension (string $shortName) : mixed
Short hand for getClassExtension()
method, except takes the short
extension name, example:
$this->asExtension('FormController')
Property | Type | Description |
---|---|---|
$shortName | string |
string
|
public
attachMany ($related, $isPublic = null
, $localKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\AttachMany
Define an attachment one-to-many relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$isPublic | mixed |
mixed
|
$localKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
attachOne ($related, boolean $isPublic = true
, $localKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\AttachOne
Define an attachment one-to-one relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$isPublic | boolean |
boolean
|
$localKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public attemptActivation (string $activationCode) : bool
Attempts to activate the given user by checking the activate code. If the user is activated already, an Exception is thrown.
Property | Type | Description |
---|---|---|
$activationCode | string |
string
|
public attemptResetPassword (string $resetCode, string $newPassword) : bool
Attempts to reset a user's password by matching the reset code generated with the user's.
Property | Type | Description |
---|---|---|
$resetCode | string |
string
|
$newPassword | string |
string
|
public attributesToArray () : array
Convert the model's attributes to an array.
public beforeLogin ()
public
belongsTo ($related, $foreignKey = null
, $parentKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\BelongsTo
Define an inverse one-to-one or many relationship.
Overridden from {@link Eloquent\Model} to allow the usage of the intermediary methods to handle the {@link $relationsData} array.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$foreignKey | mixed |
mixed
|
$parentKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
belongsToMany ($related, $table = null
, $primaryKey = null
, $foreignKey = null
, $parentKey = null
, $relatedKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\BelongsToMany
Define a many-to-many relationship.
This code is almost a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$table | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$foreignKey | mixed |
mixed
|
$parentKey | mixed |
mixed
|
$relatedKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
bindDeferred (string $relation, Illuminate\Database\Eloquent\Model $record, string $sessionKey, array $pivotData = []
)
: Winter\Storm\Database\Models\DeferredBinding
Bind a deferred relationship to the supplied record.
Property | Type | Description |
---|---|---|
$relation | string |
string
|
$record | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$sessionKey | string |
string
|
$pivotData | array |
array
|
public
bindEvent (string | Closure | QueuedClosure $event, mixed $callback = null
, integer $priority)
: self
Create a new event binding.
Property | Type | Description |
---|---|---|
$event | string | Closure | QueuedClosure |
string | Closure | QueuedClosure
|
$callback | mixed |
mixed
when the third parameter is omitted and a Closure or QueuedClosure is provided this parameter is used as an integer this is used as priority variable |
$priority | integer |
integer
|
public
bindEventOnce (string | Closure | QueuedClosure $event, QueuedClosure | Closure | null $callback = null
)
: self
Create a new event binding that fires once only
Property | Type | Description |
---|---|---|
$event | string | Closure | QueuedClosure |
string | Closure | QueuedClosure
|
$callback | QueuedClosure | Closure | null |
QueuedClosure | Closure | null
When a Closure or QueuedClosure is provided as the first parameter this parameter can be omitted |
public static bootHashable () : void
Boot the hashable trait for a model.
public static bootPurgeable () : void
Boot the purgeable trait for a model.
public static bootSoftDelete () : void
Boot the soft deleting trait for a model.
public static bootValidation () : void
Boot the validation trait for this model.
public cancelDeferred (string $sessionKey) : void
Cancel all deferred bindings to this model.
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
public checkHashValue (string $key, string $value) : bool
Checks if the supplied plain value matches the stored hash value.
Property | Type | Description |
---|---|---|
$key | string |
string
Attribute to check |
$value | string |
string
Value to check |
public checkPassword (string $password) : bool
Checks the password passed matches the user's password.
Property | Type | Description |
---|---|---|
$password | string |
string
|
public checkPersistCode (string $persistCode) : bool
Checks the given persist code.
Property | Type | Description |
---|---|---|
$persistCode | string |
string
|
public checkResetPasswordCode (string $resetCode) : bool
Checks if the provided user reset password code is valid without actually resetting the password.
Property | Type | Description |
---|---|---|
$resetCode | string |
string
|
public static clearExtendedClasses () : void
Clear the list of extended classes so they will be re-extended.
public clearResetPassword () : void
Wipes out the data associated with resetting a password.
public commitDeferred (string $sessionKey) : void
Commit all deferred bindings to this model.
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
public
static
create (array $attributes = []
, string $sessionKey = null
)
: Illuminate\Database\Eloquent\Model | static
Save a new model and return the instance.
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
$sessionKey | string |
string
|
public errors () : Illuminate\Support\MessageBag
Get validation error message collection for the Model
public extendClassWith (string $extensionName) : void
Dynamically extend a class with a specified behavior
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
public
extendableCall (string $name, array $params = null
)
: mixed
Magic method for __call()
.
Callback priority is as follows:
- "Dynamic Methods" added locally to the object via addDynamicMethod($name, $callable)
- Methods available on Behaviors that have been implemented by the object
- Pass it to the parent's __call() method if it defines one
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
public
static
extendableCallStatic (string $name, array $params = null
)
: mixed
Magic method for __callStatic()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$params | array |
array
|
public extendableConstruct ()
This method should be called as part of the constructor.
public
static
extendableExtendCallback (callable $callback, boolean $scoped = false
, $outerScope = null
)
: void
Helper method for ::extend()
static method.
Property | Type | Description |
---|---|---|
$callback | callable |
callable
|
$scoped | boolean |
boolean
|
$outerScope | mixed |
mixed
|
public extendableGet (string $name) : mixed | null
Magic method for __get()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public extendableSet (string $name, mixed $value) : void
Magic method for __set()
Property | Type | Description |
---|---|---|
$name | string |
string
|
$value | mixed |
mixed
|
public static fetched (Closure | string $callback) : void
Create a new native event for handling afterFetch().
Property | Type | Description |
---|---|---|
$callback | Closure | string |
Closure | string
|
public static fetching (Closure | string $callback) : void
Create a new native event for handling beforeFetch().
Property | Type | Description |
---|---|---|
$callback | Closure | string |
Closure | string
|
public
fireEvent (string $event, array $params = []
, boolean $halt = false
)
: array | mixed | null
Fire an event and call the listeners.
Property | Type | Description |
---|---|---|
$event | string |
string
Event name |
$params | array |
array
Event parameters |
$halt | boolean |
boolean
Halt after first non-null result |
If halted, the first non-null result. If not halted, an array of event results. Returns null if no listeners returned a result.
public static flushDuplicateCache () : void
Flush the memory cache.
public static flushEventListeners () : void
Remove all of the event listeners for the model Also flush registry of models that had events booted Allows painless unit testing.
public forceDelete () : void
Force a hard delete on a soft deleted model.
public
forceSave ($options = null
, $sessionKey = null
)
: bool
Force save the model even if validation fails.
Property | Type | Description |
---|---|---|
$options | mixed |
mixed
|
$sessionKey | mixed |
mixed
|
public freshTimestamp () : Illuminate\Support\Carbon
Get a fresh timestamp for the model.
public
fromDateTime (DateTime | int | null $value = null
)
: string | null
Convert a DateTime to a storable string.
Property | Type | Description |
---|---|---|
$value | DateTime | int | null |
DateTime | int | null
|
public getActivationCode () : string
Get an activation code for the given user.
public getAttribute (string $key) : mixed
Get an attribute from the model.
Overrides {@link Eloquent} to support loading from property-defined relations.
Property | Type | Description |
---|---|---|
$key | string |
string
|
public getAttributeValue (string $key) : mixed
Get a plain attribute (not a relationship).
Property | Type | Description |
---|---|---|
$key | string |
string
|
public getAuthIdentifier () : mixed
Get the unique identifier for the user.
public getAuthIdentifierName () : string
Get the name of the unique identifier for the user.
public getAuthPassword () : string
Get the password for the user.
public getClassExtension (string $name) : mixed
Returns a behavior object from an extendable class, example:
$this->getClassExtension('Backend.Behaviors.FormController')
Property | Type | Description |
---|---|---|
$name | string |
string
Fully qualified behavior name |
public getClassMethods () : array
Get a list of class methods, extension equivalent of get_class_methods()
public getDeletedAtColumn () : string
Get the name of the "deleted at" column.
public getDynamicProperties () : array
Returns all dynamic properties and their values
['property' => 'value']
public getGroups () : array
Returns an array of groups which the given user belongs to.
public getHashableAttributes () : array
Returns a collection of fields that will be hashed.
public getIsActivatedAttribute (mixed $activated) : bool
Get mutator for giving the activated property.
Property | Type | Description |
---|---|---|
$activated | mixed |
mixed
|
public getJsonable () : array
Get the jsonable attributes name
public getLogin () : mixed
Returns the user's login.
public getLoginName () : string
Returns the name for the user's login.
public getObservableEvents () : array
Get the observable event names.
public getOriginalHashValue ($attribute) : mixed
Returns the original values of any hashed attributes.
Property | Type | Description |
---|---|---|
$attribute | mixed |
mixed
|
public getOriginalHashValues () : array
Returns the original values of any hashed attributes.
public getOriginalPurgeValue ($attribute)
Returns the original values of any purged attributes.
Property | Type | Description |
---|---|---|
$attribute | mixed |
mixed
|
public getOriginalPurgeValues ()
Returns the original values of any purged attributes.
public getPurgeableAttributes ()
Returns a collection of fields that will be hashed.
public getQualifiedDeletedAtColumn () : string
Get the fully qualified "deleted at" column.
public
getRandomString (integer $length = 42
)
: string
Generate a random string
Property | Type | Description |
---|---|---|
$length | integer |
integer
|
public getRelationDefinition (string $name) : array | null
Returns relationship details from a supplied name.
Property | Type | Description |
---|---|---|
$name | string |
string
Relation name |
public getRelationDefinitions () : array
Returns relationship details for all relations defined on this model.
public getRelationType (string $name) : string | null
Returns a relationship type based on a supplied name.
Property | Type | Description |
---|---|---|
$name | string |
string
|
public getRelationTypeDefinition (string $type, string $name) : string | null
Returns the given relation definition.
Property | Type | Description |
---|---|---|
$type | string |
string
Relation type |
$name | string |
string
Relation name |
public getRelationTypeDefinitions (string $type) : array | string | null
Returns all defined relations of given type.
Property | Type | Description |
---|---|---|
$type | string |
string
Relation type |
public getRelationValue ($relationName)
Returns a relation key value(s), not as an object.
Property | Type | Description |
---|---|---|
$relationName | mixed |
mixed
|
public getRememberToken () : string
Get the token value for the "remember me" session.
public getRememberTokenName () : string
Get the column name for the "remember me" token.
public getReminderEmail () : string
Get the e-mail address where password reminders are sent.
public getResetPasswordCode () : string
Get a reset password code for the given user.
public getRole () : Winter\Storm\Auth\Models\Role | null
public
hasAccess (string | array $permissions, boolean $all = true
)
: bool
See if a user has access to the passed permission(s).
Permissions are merged from all groups the user belongs to and then are checked against the passed permission(s).
If multiple permissions are passed, the user must have access to all permissions passed through, unless the "all" flag is set to false.
Super users have access no matter what.
Property | Type | Description |
---|---|---|
$permissions | string | array |
string | array
|
$all | boolean |
boolean
|
public hasAnyAccess (array $permissions) : bool
Returns if the user has access to any of the given permissions.
Property | Type | Description |
---|---|---|
$permissions | array |
array
|
public hasGetMutator (string $key) : bool
Determine if a get mutator exists for an attribute.
Property | Type | Description |
---|---|---|
$key | string |
string
|
public
hasMany ($related, $primaryKey = null
, $localKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\HasMany
Define a one-to-many relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$localKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
hasManyThrough ($related, $through, $primaryKey = null
, $throughKey = null
, $localKey = null
, $secondLocalKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\HasManyThrough
Define a has-many-through relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$through | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$throughKey | mixed |
mixed
|
$localKey | mixed |
mixed
|
$secondLocalKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
hasOne ($related, $primaryKey = null
, $localKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\HasOne
Define a one-to-one relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$localKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
hasOneThrough ($related, $through, $primaryKey = null
, $throughKey = null
, $localKey = null
, $secondLocalKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\HasOneThrough
Define a has-one-through relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$through | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$throughKey | mixed |
mixed
|
$localKey | mixed |
mixed
|
$secondLocalKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
hasPermission (string | array $permissions, boolean $all = true
)
: bool
See if a user has access to the passed permission(s).
Permissions are merged from all groups the user belongs to and then are checked against the passed permission(s).
If multiple permissions are passed, the user must have access to all permissions passed through, unless the "all" flag is set to false.
Super users DON'T have access no matter what.
Property | Type | Description |
---|---|---|
$permissions | string | array |
string | array
|
$all | boolean |
boolean
|
public hasRelation (string $name) : bool
Checks if model has a relationship by supplied name.
Property | Type | Description |
---|---|---|
$name | string |
string
Relation name |
public hasSetMutator (string $key) : bool
Determine if a set mutator exists for an attribute.
Property | Type | Description |
---|---|---|
$key | string |
string
|
public inGroup (Group $group) : bool
See if the user is in the given group.
Property | Type | Description |
---|---|---|
$group | Group |
Group
|
public
isAttributeRequired (string $attribute, boolean $checkDependencies = true
)
: bool
Determines if an attribute is required based on the validation rules.
Property | Type | Description |
---|---|---|
$attribute | string |
string
|
$checkDependencies | boolean |
boolean
Checks the attribute dependencies (for required_if & required_with rules). Note that it will only be checked up to the next level, if another dependent rule is found then it will just assume the field is required |
public isClassExtendedWith (string $name) : bool
Check if extendable class is extended with a behavior object
Property | Type | Description |
---|---|---|
$name | string |
string
Fully qualified behavior name |
public isDeferrable (string $relationName) : bool
Returns true if a relation exists and can be deferred.
Property | Type | Description |
---|---|---|
$relationName | string |
string
|
public isGuarded (string $key) : bool
Determine if the given key is guarded.
This is an override of https://github.com/laravel/framework/commit/897d107775737a958dbd0b2f3ea37877c7526371
and allows fields that don't exist in the database to be filled if they aren't specified as "guarded", under
the pretense that they are handled in a special manner - ie. in the beforeSave
event.
Property | Type | Description |
---|---|---|
$key | string |
string
|
public isJsonable ($key) : bool
Checks if an attribute is jsonable or not.
Property | Type | Description |
---|---|---|
$key | mixed |
mixed
|
public isRelationPushable (string $name) : bool
Determines whether the specified relation should be saved when push() is called instead of save() on the model. Default: true.
Property | Type | Description |
---|---|---|
$name | string |
string
Relation name |
public isSoftDelete () : bool
Helper method to check if the model is currently being hard or soft deleted, useful in events.
public isSuperUser () : bool
Checks if the user is a super user - has access to everything regardless of permissions.
public jsonable (array $jsonable) : $this
Set the jsonable attributes for the model.
Property | Type | Description |
---|---|---|
$jsonable | array |
array
|
public
static
make (array $attributes = []
)
: Illuminate\Database\Eloquent\Model | static
Create a new model and return the instance.
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
public makeHashValue (string $key, string $value) : string
Hashes an attribute value and saves it in the original locker.
Property | Type | Description |
---|---|---|
$key | string |
string
Attribute |
$value | string |
string
Value to hash |
Hashed value
public makeRelation (string $name) : Winter\Storm\Database\Model | null
Returns a new instance of a related model
Property | Type | Description |
---|---|---|
$name | string |
string
|
public methodExists (string $name) : bool
Checks if a method exists, extension equivalent of method_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public
morphMany ($related, $name, $type = null
, $id = null
, $localKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\MorphMany
Define a polymorphic one-to-many relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$name | mixed |
mixed
|
$type | mixed |
mixed
|
$id | mixed |
mixed
|
$localKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
morphOne ($related, $name, $type = null
, $id = null
, $localKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\MorphOne
Define a polymorphic one-to-one relationship.
This code is a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$name | mixed |
mixed
|
$type | mixed |
mixed
|
$id | mixed |
mixed
|
$localKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
morphTo ($name = null
, $type = null
, $id = null
, $ownerKey = null
)
: Winter\Storm\Database\Relations\MorphTo
Define an polymorphic, inverse one-to-one or many relationship.
Overridden from {@link Eloquent\Model} to allow the usage of the intermediary methods to handle the relation.
Property | Type | Description |
---|---|---|
$name | mixed |
mixed
|
$type | mixed |
mixed
|
$id | mixed |
mixed
|
$ownerKey | mixed |
mixed
|
public
morphToMany ($related, $name, $table = null
, $primaryKey = null
, $foreignKey = null
, $parentKey = null
, $relatedKey = null
, boolean $inverse = false
, $relationName = null
)
: Winter\Storm\Database\Relations\MorphToMany
Define a polymorphic many-to-many relationship.
This code is almost a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$name | mixed |
mixed
|
$table | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$foreignKey | mixed |
mixed
|
$parentKey | mixed |
mixed
|
$relatedKey | mixed |
mixed
|
$inverse | boolean |
boolean
|
$relationName | mixed |
mixed
|
public
morphedByMany ($related, $name, $table = null
, $primaryKey = null
, $foreignKey = null
, $parentKey = null
, $relatedKey = null
, $relationName = null
)
: Winter\Storm\Database\Relations\MorphToMany
Define a polymorphic many-to-many inverse relationship.
This code is almost a duplicate of Eloquent but uses a Storm relation class.
Property | Type | Description |
---|---|---|
$related | mixed |
mixed
|
$name | mixed |
mixed
|
$table | mixed |
mixed
|
$primaryKey | mixed |
mixed
|
$foreignKey | mixed |
mixed
|
$parentKey | mixed |
mixed
|
$relatedKey | mixed |
mixed
|
$relationName | mixed |
mixed
|
public
newCollection (array $models = []
)
: Winter\Storm\Database\Collection
Create a new Model Collection instance.
Property | Type | Description |
---|---|---|
$models | array |
array
|
public newEloquentBuilder (Winter\Storm\Database\QueryBuilder $query) : Winter\Storm\Database\Builder
Create a new Eloquent query builder for the model.
Property | Type | Description |
---|---|---|
$query | Winter\Storm\Database\QueryBuilder |
public
newFromBuilder (array $attributes = []
, $connection = null
)
: Illuminate\Database\Eloquent\Model | static
Create a new model instance that is existing.
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
$connection | mixed |
mixed
|
public
newPivot (Illuminate\Database\Eloquent\Model $parent, array $attributes, string $table, bool $exists, string | null $using = null
)
: Winter\Storm\Database\Pivot
Create a generic pivot model instance.
Property | Type | Description |
---|---|---|
$parent | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$attributes | array |
array
|
$table | string |
string
|
$exists | bool |
bool
|
$using | string | null |
string | null
|
public newRelationPivot (string $relationName, Winter\Storm\Database\Model $parent, array $attributes, string $table, bool $exists) : Winter\Storm\Database\Pivot | null
Create a pivot model instance specific to a relation.
Property | Type | Description |
---|---|---|
$relationName | string |
string
|
$parent | Winter\Storm\Database\Model | |
$attributes | array |
array
|
$table | string |
string
|
$exists | bool |
bool
|
public offsetExists (mixed $offset) : bool
This a custom piece of logic specifically to satisfy Twig's desire to return a relation object instead of loading the related model.
Property | Type | Description |
---|---|---|
$offset | mixed |
mixed
|
public static onlyTrashed () : Illuminate\Database\Eloquent\Builder | static
Get a new query builder that only includes soft deletes.
public propertyExists (string $name) : bool
Checks if a property exists, extension equivalent of property_exists()
Property | Type | Description |
---|---|---|
$name | string |
string
|
public
purgeAttributes (array | string $attributesToPurge = null
)
: array
Removes purged attributes from the dataset, used before saving.
Property | Type | Description |
---|---|---|
$attributesToPurge | array | string |
array | string
Attribute(s) to purge, if unspecified, $purgable property is used |
Current attribute set
public
push (array $options = []
, string | null $sessionKey = null
)
: bool
Save the model and all of its relationships.
Property | Type | Description |
---|---|---|
$options | array |
array
|
$sessionKey | string | null |
string | null
|
public reload () : Illuminate\Database\Eloquent\Model | static
Reloads the model attributes from the database.
public
reloadRelations (string $relationName = null
)
: void
Reloads the model relationship cache.
Property | Type | Description |
---|---|---|
$relationName | string |
string
|
public removeGroup (Group $group) : bool
Removes the user from the given group.
Property | Type | Description |
---|---|---|
$group | Group |
Group
|
public restore () : bool | null
Restore a soft-deleted model instance.
public restorePurgedValues ()
Restores the original values of any purged attributes.
public static restored (Closure | string $callback) : void
Register a restored model event with the dispatcher.
Property | Type | Description |
---|---|---|
$callback | Closure | string |
Closure | string
|
public static restoring (Closure | string $callback) : void
Register a restoring model event with the dispatcher.
Property | Type | Description |
---|---|---|
$callback | Closure | string |
Closure | string
|
public
save (array $options = []
, string | null $sessionKey = null
)
: bool
Save the model to the database.
Property | Type | Description |
---|---|---|
$options | array |
array
|
$sessionKey | string | null |
string | null
|
public setAttribute (string $key, mixed $value) : mixed | null
Set a given attribute on the model.
Property | Type | Description |
---|---|---|
$key | string |
string
|
$value | mixed |
mixed
|
public setPasswordAttribute ($value)
Protects the password from being reset to null.
Property | Type | Description |
---|---|---|
$value | mixed |
mixed
|
public setPermissionsAttribute (string $permissions) : void
Validate any set permissions.
Property | Type | Description |
---|---|---|
$permissions | string |
string
|
public setRememberToken (string | null $value) : void
Set the token value for the "remember me" session.
Property | Type | Description |
---|---|---|
$value | string | null |
string | null
|
public setValidationAttributeName (string $attr, string $name) : void
Programatically sets the validation attribute names, will take lower priority
to model defined attribute names found in $attributeNames
.
Property | Type | Description |
---|---|---|
$attr | string |
string
|
$name | string |
string
|
public setValidationAttributeNames (array $attributeNames) : void
Programatically sets multiple validation attribute names.
Property | Type | Description |
---|---|---|
$attributeNames | array |
array
|
public trashed () : bool
Determine if the model instance has been soft-deleted.
public unbindDeferred (string $relation, Illuminate\Database\Eloquent\Model $record, string $sessionKey) : Winter\Storm\Database\Models\DeferredBinding
Unbind a deferred relationship to the supplied record.
Property | Type | Description |
---|---|---|
$relation | string |
string
|
$record | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$sessionKey | string |
string
|
public
unbindEvent (string | array | object $event = null
)
: self
Destroys an event binding.
Property | Type | Description |
---|---|---|
$event | string | array | object |
string | array | object
Event to destroy |
public
validate ($rules = null
, $customMessages = null
, $attributeNames = null
)
: bool
Validate the model instance
Property | Type | Description |
---|---|---|
$rules | mixed |
mixed
|
$customMessages | mixed |
mixed
|
$attributeNames | mixed |
mixed
|
public static validated (Closure | string $callback) : void
Create a new native event for handling afterValidate().
Property | Type | Description |
---|---|---|
$callback | Closure | string |
Closure | string
|
public static validating (Closure | string $callback) : void
Create a new native event for handling beforeValidate().
Property | Type | Description |
---|---|---|
$callback | Closure | string |
Closure | string
|
public static withTrashed () : Illuminate\Database\Eloquent\Builder | static
Get a new query builder that includes soft deletes.
protected addRelation (string $type, string $name, array $config) : void
Dynamically add the provided relationship configuration to the local properties
Property | Type | Description |
---|---|---|
$type | string |
string
|
$name | string |
string
|
$config | array |
array
|
protected afterFetch ()
Handle the "fetched" model event
protected afterSave ()
Handle the "saved" model event
protected afterUpdate ()
Handle the "updated" model event
protected asDateTime (mixed $value) : Carbon\Carbon
Return a timestamp as DateTime object.
Property | Type | Description |
---|---|---|
$value | mixed |
mixed
|
protected beforeCreate ()
Handle the "creating" model event
protected beforeDelete ()
Handle the "deleting" model event
protected beforeFetch ()
Handle the "fetching" model event
protected beforeSave ()
Handle the "saving" model event
protected beforeUpdate ()
Handle the "updating" model event
protected bootNicerEvents ()
Bind some nicer events to this model, in the format of method overrides.
protected commitDeferredAfter (string $sessionKey) : void
Internally used method to commit all deferred bindings after saving.
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
protected commitDeferredBefore (string $sessionKey) : void
Internally used method to commit all deferred bindings before saving.
It is a rare need to have to call this, since it only applies to the "belongs to" relationship which generally does not need deferring.
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
protected
commitDeferredOfType (string $sessionKey, $include = null
, $exclude = null
)
: void
Internal method for committing deferred relations.
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
$include | mixed |
mixed
|
$exclude | mixed |
mixed
|
protected emitterEventSortEvents (string $eventName) : void
Sort the listeners for a given event by priority.
Property | Type | Description |
---|---|---|
$eventName | string |
string
|
protected extendableIsAccessible (mixed $class, string $propertyName) : bool
Checks if a property is accessible, property equivalent of is_callable()
Property | Type | Description |
---|---|---|
$class | mixed |
mixed
|
$propertyName | string |
string
|
protected extensionExtractMethods (string $extensionName, object $extensionObject) : void
Extracts the available methods from a behavior and adds it to the list of callable methods.
Property | Type | Description |
---|---|---|
$extensionName | string |
string
|
$extensionObject | object |
object
|
protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null
Gets the class loader
protected extensionNormalizeClassName (string $name) : string
Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes
Property | Type | Description |
---|---|---|
$name | string |
string
|
protected getDeferrableRelationTypes () : array
Returns all possible relation types that can be deferred.
protected getDeferredBindingRecords (string $sessionKey) : Winter\Storm\Database\Collection
Returns any outstanding binding records for this model.
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
protected
getMorphs (string $name, string | null $type = null
, string | null $id = null
)
: array
Get the polymorphic relationship columns.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$type | string | null |
string | null
|
$id | string | null |
string | null
|
protected getRelationCaller ()
Finds the calling function name from the stack trace.
protected getRelationDefaults (string $type) : array
Returns default relation arguments for a given type.
Property | Type | Description |
---|---|---|
$type | string |
string
Relation type |
protected getRelationValidationValue ($relationName)
Attachments validate differently to their simple values.
Property | Type | Description |
---|---|---|
$relationName | mixed |
mixed
|
protected getValidationAttributes () : array
Returns the model data used for validation.
protected handleRelation (string $relationName) : Illuminate\Database\Eloquent\Relations\Relation
Looks for the relation and does the correct magic as Eloquent would require inside relation methods. For more information, read the documentation of the mentioned property.
Property | Type | Description |
---|---|---|
$relationName | string |
string
the relation key, camel-case version |
protected
static
makeValidator ($data, $rules, $customMessages, $attributeNames, $connection = null
)
: Illuminate\Contracts\Validation\Validator
Instantiates the validator used by the validation process, depending if the class is being used inside or outside of Laravel. Optional connection string to make the validator use a different database connection than the default connection.
Property | Type | Description |
---|---|---|
$data | mixed |
mixed
|
$rules | mixed |
mixed
|
$customMessages | mixed |
mixed
|
$attributeNames | mixed |
mixed
|
$connection | mixed |
mixed
|
protected morphEagerTo (string $name, string $type, string $id, string $ownerKey) : Winter\Storm\Database\Relations\MorphTo
Define a polymorphic, inverse one-to-one or many relationship.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$type | string |
string
|
$id | string |
string
|
$ownerKey | string |
string
|
protected
morphInstanceTo (string $target, string $name, string $type, string $id, string | null $ownerKey = null
)
: Winter\Storm\Database\Relations\MorphTo
Define a polymorphic, inverse one-to-one or many relationship.
Property | Type | Description |
---|---|---|
$target | string |
string
|
$name | string |
string
|
$type | string |
string
|
$id | string |
string
|
$ownerKey | string | null |
string | null
|
protected newBaseQueryBuilder () : Winter\Storm\Database\QueryBuilder
protected
parseEventAndPayload (mixed $event, mixed $payload = null
)
: array
Parse the given event and payload and prepare them for dispatching.
Property | Type | Description |
---|---|---|
$event | mixed |
mixed
|
$payload | mixed |
mixed
|
protected performDeleteOnModel () : mixed
Perform the actual delete query on this model instance.
protected performDeleteOnRelations () : void
Locates relations with delete flag and cascades the delete event.
protected performRestoreOnRelations () : void
Locates relations with softDelete flag and cascades the restore event.
protected performSoftDeleteOnRelations () : void
Locates relations with softDelete flag and cascades the delete event.
protected processRuleFieldNames (array $rules) : array
Processes field names in a rule array.
Converts any field names using array notation (ie. field[child]
) into dot notation (ie. field.child
)
Property | Type | Description |
---|---|---|
$rules | array |
array
Rules array |
protected processValidationRules ($rules)
Process rules
Property | Type | Description |
---|---|---|
$rules | mixed |
mixed
|
protected processValidationUniqueRule (string $definition, string $fieldName) : string
Rebuilds the unique validation rule to force for the existing ID
Property | Type | Description |
---|---|---|
$definition | string |
string
|
$fieldName | string |
string
|
protected runSoftDelete () : void
Perform the actual delete query on this model instance.
protected
saveInternal (array $options = []
)
: bool
Save the model to the database. Is used by {@link save()} and {@link forceSave()}.
Property | Type | Description |
---|---|---|
$options | array |
array
|
protected setRelationValue ($relationName, $value)
Sets a relation value directly from its attribute.
Property | Type | Description |
---|---|---|
$relationName | mixed |
mixed
|
$value | mixed |
mixed
|
protected
validateRelationArgs ($relationName, $optional, array $required = []
)
Validate relation supplied arguments.
Property | Type | Description |
---|---|---|
$relationName | mixed |
mixed
|
$optional | mixed |
mixed
|
$required | array |
array
|