Role
Role model
class Winter\Storm\Auth\Models\Role
extends Winter\Storm\Database\Model
implements
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
|
|
HidesAttributes
|
Hides and shows attributes for serialization. |
Purgeable
|
|
Validation
|
Properties
public
$hasMany
:
array
= {"users":{}}
Relations
public
$rules
:
array
= {"name":"required|between:4,16|unique:role"}
Validation rules
protected
$allowedPermissionsValues
:
array
= [0,1]
Allowed permissions values.
Possible options: 0 => Remove. 1 => Add.
protected
$guarded
:
string[]
|
bool
= []
The attributes that aren't mass assignable.
protected
$jsonable
:
array
= ["permissions"]
List of attribute names which are json encoded and decoded from the database.
protected
$table
:
string
= "roles"
The table associated with the model.
public
$attachMany
:
mixed
= []
protected $attachMany = [ 'pictures' => ['Winter\Storm\Database\Attach\File', 'name'=> 'imageable'] ];
public
$attachOne
:
mixed
= []
protected $attachOne = [ 'picture' => ['Winter\Storm\Database\Attach\File', 'public' => false] ];
public
$attributes
:
array
= []
Make the model's attributes public so behaviors can modify them.
public
$belongsTo
:
mixed
= []
protected $belongsTo = [ 'parent' => ['Category', 'key' => 'parent_id'] ];
public
$belongsToMany
:
mixed
= []
protected $belongsToMany = [ 'groups' => ['Group', 'table'=> 'join_groups_users'] ];
public
$duplicateCache
:
bool
= true
Indicates if duplicate queries from this model should be cached in memory.
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
$dates
:
array
= []
List of datetime attributes to convert to an instance of Carbon/DateTime objects.
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
$originalPurgeableValues
:
array
= []
List of original attribute values before they were purged.
protected
$purgeable
:
array
= []
List of attributes which should not be saved to the database.
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
$validationDefaultAttrNames
:
array
= []
Default custom attribute names.
protected $validationErrors : Illuminate\Support\MessageBag
The message bag instance containing validation error messages
Methods
public
hasAccess (string | array $permissions, boolean $all = true
)
: bool
See if a role has access to the passed permission(s).
If multiple permissions are passed, the role must have access to all permissions passed through, unless the "all" flag is set to false.
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 setPermissionsAttribute (string $permissions) : void
Validate the permissions when set.
Property | Type | Description |
---|---|---|
$permissions | string |
string
|
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 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
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
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 attributesToArray () : array
Convert the model's attributes to an array.
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 bootPurgeable () : void
Boot the purgeable 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 static clearExtendedClasses () : void
Clear the list of extended classes so they will be re-extended.
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
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 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 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 getDynamicProperties () : array
Returns all dynamic properties and their values
['property' => 'value']
public getJsonable () : array
Get the jsonable attributes name
public getObservableEvents () : array
Get the observable event names.
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 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 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 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
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 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 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 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 restorePurgedValues ()
Restores the original values of any purged attributes.
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 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 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
|
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 afterCreate ()
Handle the "created" model event
protected afterDelete ()
Handle the "deleted" model event
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 () : void
Perform the actual delete query on this model instance.
protected performDeleteOnRelations () : void
Locates relations with delete 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
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
|