File

File attachment model

 class Winter\Storm\Database\Attach\File
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
Sortable

Sortable model trait

Properties

public $data : mixed

A local file name or an instance of an uploaded file, objects of the \Symfony\Component\HttpFoundation\File\UploadedFile class.

public static $imageExtensions : string[]

Known image extensions.

public $morphTo : array

Relations

protected $appends : array

Add fields to array/json access

protected $autoMimeTypes : array

Mime types

protected $fillable : string[]

The attributes that are mass assignable.

protected $guarded : string[]

The attributes that aren't mass assignable.

protected $hidden : array<int,string>

Hidden fields from array/json access

protected $table : string

The table associated with the model.

public $attachMany : mixed

Inherited from Model

protected $attachMany = [ 'pictures' => ['Winter\Storm\Database\Attach\File', 'name'=> 'imageable'] ];

public $attachOne : mixed

Inherited from Model

protected $attachOne = [ 'picture' => ['Winter\Storm\Database\Attach\File', 'public' => false] ];

public $attributes : array

Inherited from Model

Make the model's attributes public so behaviors can modify them.

public $belongsTo : mixed

Inherited from Model

protected $belongsTo = [ 'parent' => ['Category', 'key' => 'parent_id'] ];

public $belongsToMany : mixed

Inherited from Model

protected $belongsToMany = [ 'groups' => ['Group', 'table'=> 'join_groups_users'] ];

public $duplicateCache : bool

Inherited from Model

Indicates if duplicate queries from this model should be cached in memory.

public $hasMany : array

Inherited from Model

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

Inherited from Model

protected $hasManyThrough = [ 'posts' => ['Posts', 'through' => 'User'] ];

public $hasOne : mixed

Inherited from Model

protected $hasOne = [ 'owner' => ['User', 'key' => 'user_id'] ];

public $hasOneThrough : mixed

Inherited from Model

protected $hasOneThrough = [ 'post' => ['Posts', 'through' => 'User'] ];

public $implement : string | array | null

Inherited from Model

Extensions implemented by this class.

public $morphMany : mixed

Inherited from Model

protected $morphMany = [ 'log' => ['History', 'name' => 'user'] ];

public $morphOne : mixed

Inherited from Model

protected $morphOne = [ 'log' => ['History', 'name' => 'user'] ];

public $morphToMany : mixed

Inherited from Model

protected $morphToMany = [ 'tag' => ['Tag', 'table' => 'tagables', 'name' => 'tagable'] ];

public $morphedByMany : mixed

Inherited from Model

public $sessionKey : string

Inherited from Model

A unique session key used for deferred binding.

public $trimStringAttributes : bool

Inherited from Model

Indicates if all string model attributes will be trimmed prior to saving.

protected $dates : array

Inherited from Model

List of datetime attributes to convert to an instance of Carbon/DateTime objects.

protected $emitterEventCollection : array

Inherited from Model

Collection of registered events.

protected $emitterEventSorted : array

Inherited from Model

Sorted collection of events.

protected $emitterSingleEventCollection : array

Inherited from Model

Collection of registered events to be fired once only.

protected static $eventsBooted : array

Inherited from Model

The array of models booted events.

protected static $extendableCallbacks : array

Inherited from Model

Used to extend the constructor of an extendable class. Eg:

Class::extend(function($obj) { })

protected static $extendableClassLoader : ClassLoader | null

Inherited from Model

Class loader instance.

protected static $extendableGuardProperties : bool

Inherited from Model

Indicates if dynamic properties can be created.

protected static $extendableStaticMethods : array

Inherited from Model

Collection of static methods used by behaviors.

protected $extensionData : array

Inherited from Model

Class reflection information, including behaviors.

protected $jsonable : array

Inherited from Model

List of attribute names which are json encoded and decoded from the database.

protected $originalPurgeableValues : array

Inherited from Model

List of original attribute values before they were purged.

protected $purgeable : array

Inherited from Model

List of attributes which should not be saved to the database.

protected static $relationTypes : array

Inherited from Model

Excepted relationship types, used to cycle and verify relationships.

Methods

public afterDelete () : void

After model is deleted

  • clean up it's thumbnails
Returns
void

public beforeSave () : void

Before the model is saved

  • check if new file data has been supplied, eg: $model->data = Input::file('something');
Returns
void

public deleteThumbs () : void

Delete all thumbnails for this file.

Returns
void

public fromData (string $data, string $filename) : static

Creates a file object from raw data.

Parameters
Property Description
$data
string

The raw data.

$filename
string

The name of the file.

Returns
static

public fromFile (string $filePath, $filename = null) : static

Creates a file object from a file on the local filesystem.

Parameters
Property Description
$filePath
string

The path to the file.

$filename
mixed
Returns
static

public fromPost (UploadedFile $uploadedFile) : static

Creates a file object from a file an uploaded file.

Parameters
Property Description
$uploadedFile
UploadedFile

The uploaded file.

Returns
static

public fromStorage (string $filePath) : static

Creates a file object from a file on the disk returned by $this->getDisk()

Parameters
Property Description
$filePath
string
Returns
static

public fromUrl (string $url, string | null $filename = null) : static

Creates a file object from url

Parameters
Property Description
$url
string

The URL to retrieve and store.

$filename
string | null

The name of the file. If null, the filename will be extracted from the URL.

Returns
static

public getCacheKey (string | null $path = null) : string

Returns the cache key used for the hasFile method

Parameters
Property Description
$path
string | null

The path to get the cache key for

Returns
string

public getContentType () : string | null

Returns the file content type.

Returns null if the file content type cannot be determined.

Returns
string | null

public getContents (string | null $fileName = null) : string

Get file contents from storage device.

Parameters
Property Description
$fileName
string | null
Returns
string

public getDisk () : FilesystemAdapter

Returns the storage disk the file is stored on

Returns
FilesystemAdapter

public getDiskPath (string | null $fileName = null) : string

Returns the path to the file, relative to the storage disk.

Parameters
Property Description
$fileName
string | null
Returns
string

public getExtension () : string

Returns the file extension.

Returns
string

public getExtensionAttribute () : string

Helper attribute for getExtension.

Returns
string

public getFilename () : string

Returns the file name without path

Returns
string

public getHeightAttribute () : string | int | null

Helper attribute for get image height.

Returns null if this file is not an image.

Returns
string | int | null

public getLastModified (string | null $fileName = null) : int

Returns the last modification date as a UNIX timestamp.

Parameters
Property Description
$fileName
string | null
Returns
int

public getLocalPath () : string

Returns a local path to this file. If the file is stored remotely, it will be downloaded to a temporary directory.

Returns
string

public static getMaxFilesize () : float

Returns the maximum size of an uploaded file as configured in php.ini in kilobytes (rounded)

Returns
float

public getPath (string | null $fileName = null) : string

Returns the public address to access the file.

Parameters
Property Description
$fileName
string | null
Returns
string

public getPathAttribute () : string

Helper attribute for getPath.

Returns
string

public getPublicPath () : string

Define the public address for the storage path.

Returns
string

public getSizeAttribute () : string

Helper attribute for file size in human format.

Returns
string

public getStorageDirectory () : string

Define the internal storage path, override this method to define.

Returns
string

public getTempPath () : string

Define the internal working path, override this method to define.

Returns
string

public getThumb (int $width, int $height, array $options = []) : string

Generates and returns a thumbnail path.

Parameters
Property Description
$width
int
$height
int
$options
array

[ 'mode' => 'auto', 'offset' => [0, 0], 'quality' => 90, 'sharpen' => 0, 'interlace' => false, 'extension' => 'auto', ]

Returns
string

The URL to the generated thumbnail

public getThumbFilename (int $width, int $height, array $options = []) : string

Generates a thumbnail filename.

Parameters
Property Description
$width
int
$height
int
$options
array

[ 'mode' => 'auto', 'offset' => [0, 0], 'quality' => 90, 'sharpen' => 0, 'interlace' => false, 'extension' => 'auto', ]

Returns
string

The filename of the thumbnail

public getWidthAttribute () : string | int | null

Helper attribute for get image width.

Returns null if this file is not an image.

Returns
string | int | null

public isImage () : bool

Checks if the file extension is an image and returns true or false.

Returns
bool

public isPublic () : bool

Determines if the file is flagged "public" or not.

Returns
bool

public output (string $disposition = "inline", boolean $returnResponse = false) : Illuminate\Http\Response | void

Outputs the raw file contents.

Parameters
Property Description
$disposition
string

The Content-Disposition to set, defaults to inline

$returnResponse
boolean

Defaults to false, returns a Response object instead of directly outputting to the browser

Returns
Illuminate\Http\Response | void

public outputThumb (int $width, int $height, array $options = [], boolean $returnResponse = false) : Illuminate\Http\Response | void

Outputs the raw thumbfile contents.

Parameters
Property Description
$width
int
$height
int
$options
array

[ 'mode' => 'auto', 'offset' => [0, 0], 'quality' => 90, 'sharpen' => 0, 'interlace' => false, 'extension' => 'auto', 'disposition' => 'inline', ]

$returnResponse
boolean

Defaults to false, returns a Response object instead of directly outputting to the browser

Returns
Illuminate\Http\Response | void

public setDataAttribute (mixed $value) : void

Used only when filling attributes.

Parameters
Property Description
$value
mixed
Returns
void

public sizeToString () : string

Returns the file size as string.

Returns
string

protected copyLocalToStorage (string $localPath, string $storagePath) : string | bool

Copy the local file to Storage

Parameters
Property Description
$localPath
string
$storagePath
string
Returns
string | bool

protected copyStorageToLocal (string $storagePath, string $localPath) : int

Copy the Storage to local file

Parameters
Property Description
$storagePath
string
$localPath
string
Returns
int

The filesize of the copied file.

protected deleteEmptyDirectory (string | null $dir = null) : void

Checks if directory is empty then deletes it, three levels up to match the partition directory.

Parameters
Property Description
$dir
string | null

Directory to check and delete if empty.

Returns
void

protected deleteFile (string | null $fileName = null) : void

Delete file contents from storage device.

Parameters
Property Description
$fileName
string | null
Returns
void

protected getDefaultThumbOptions (array $override = []) : array

Returns the default thumbnail options.

Parameters
Property Description
$override
array
Returns
array

protected getDiskName () : string

Generates a disk name from the supplied file name.

Returns
string

protected getImageDimensions () : array | false

Get image dimensions

Returns
array | false

protected getLocalRootPath () : string

If working with local storage, determine the absolute local path.

Returns
string

protected getLocalTempPath ($path = null) : string

Returns a temporary local path to work from.

Parameters
Property Description
$path
mixed
Returns
string

protected getPartitionDirectory () : string

Generates a partition for the file.

For example, returns /ABC/DE1/234 for an name of ABCDE1234.

Returns
string

protected hasFile (string | null $fileName = null) : bool

Check file exists on storage device.

Parameters
Property Description
$fileName
string | null
Returns
bool

protected isDirectoryEmpty (string | null $dir = null) : bool

Returns true if a directory contains no files.

Parameters
Property Description
$dir
string | null

Directory to check.

Returns
bool

protected isLocalStorage () : bool

Returns true if the storage engine is local.

Returns
bool

protected makeThumb (string $thumbFile, string $thumbPath, integer $width, integer $height, array $options = []) : void

Generate a thumbnail

Parameters
Property Description
$thumbFile
string
$thumbPath
string
$width
integer
$height
integer
$options
array
Returns
void

protected putFile (string $sourcePath, string | null $destinationFileName = null) : bool

Saves a file

Parameters
Property Description
$sourcePath
string

An absolute local path to a file name to read from.

$destinationFileName
string | null

A storage file name to save to.

Returns
bool

protected storageCmd () : mixed

Calls a method against File or Storage depending on local storage.

This allows local storage outside the storage/app folder and is also good for performance. For local storage, every argument is prefixed with the local root path. Props to Laravel for the unified interface.

Returns
mixed

public __call ($name, $params)

Inherited from Model
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

public static __callStatic ($name, $params)

Inherited from Model
Parameters
Property Description
$name
mixed
$params
mixed
Returns
mixed

public __construct (array $attributes = [])

Inherited from Model

Constructor

Parameters
Property Description
$attributes
array
Returns
mixed

public __get ($name)

Inherited from Model
Parameters
Property Description
$name
mixed
Returns
mixed

public __isset (string $key) : bool

Inherited from Model

Determine if an attribute or relation exists on the model.

Parameters
Property Description
$key
string
Returns
bool

public __set ($name, $value)

Inherited from Model
Parameters
Property Description
$name
mixed
$value
mixed
Returns
mixed

public addAttachManyRelation (string $name, array $config) : void

Inherited from Model

Dynamically add an AttachMany relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addAttachOneRelation (string $name, array $config) : void

Inherited from Model

Dynamically add an AttachOne relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addBelongsToManyRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a BelongsToMany relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addBelongsToRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a BelongsTo relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addCasts (array $attributes) : void

Inherited from Model

Add attribute casts for the model.

Parameters
Property Description
$attributes
array
Returns
void

public addDateAttribute (string $attribute) : void

Inherited from Model

Adds a datetime attribute to convert to an instance of Carbon/DateTime object.

Parameters
Property Description
$attribute
string
Returns
void

public addDynamicMethod (string $dynamicName, callable $method, string $extension = null)

Inherited from Model

Programmatically adds a method to the extendable class

Parameters
Property Description
$dynamicName
string
$method
callable
$extension
string
Returns
mixed

public addDynamicProperty (string $dynamicName, mixed $value = null) : void

Inherited from Model

Programmatically adds a property to the extendable class

Parameters
Property Description
$dynamicName
string

The name of the property to add

$value
mixed

The value of the property

Returns
void

public addFillable (array | string | null $attributes = null) : void

Inherited from Model

Add fillable attributes for the model.

Parameters
Property Description
$attributes
array | string | null
Returns
void

public addHasManyRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a HasMany relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addHasManyThroughRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a(n) HasManyThrough relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addHasOneRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a HasOne relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addHasOneThroughRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a(n) HasOneThrough relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addHidden (array | string | null $attributes = null) : void

Inherited from Model

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.

Parameters
Property Description
$attributes
array | string | null
Returns
void

public addJsonable (array | string | null $attributes = null) : void

Inherited from Model

Add jsonable attributes for the model.

Parameters
Property Description
$attributes
array | string | null
Returns
void

public addMorphManyRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a MorphMany relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addMorphOneRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a MorphOne relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addMorphToManyRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a MorphToMany relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addMorphToRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a MorphTo relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addMorphedByManyRelation (string $name, array $config) : void

Inherited from Model

Dynamically add a MorphedByMany relationship

Parameters
Property Description
$name
string
$config
array
Returns
void

public addPurgeable (array | string | null $attributes = null) : $this

Inherited from Model

Adds an attribute to the purgeable attributes list

Parameters
Property Description
$attributes
array | string | null
Returns
$this

public addVisible (array | string | null $attributes = null) : void

Inherited from Model

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.

Parameters
Property Description
$attributes
array | string | null
Returns
void

public alwaysPush (array $options = [], string | null $sessionKey = null) : bool

Inherited from Model

Pushes the first level of relations even if the parent model has no changes.

Parameters
Property Description
$options
array
$sessionKey
string | null
Returns
bool

public asExtension (string $shortName) : mixed

Inherited from Model

Short hand for getClassExtension() method, except takes the short extension name, example:

$this->asExtension('FormController')

Parameters
Property Description
$shortName
string
Returns
mixed

public attachMany ($related, $isPublic = null, $localKey = null, $relationName = null) : Winter\Storm\Database\Relations\AttachMany

Inherited from Model

Define an attachment one-to-many relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$isPublic
mixed
$localKey
mixed
$relationName
mixed
Returns

public attachOne ($related, boolean $isPublic = true, $localKey = null, $relationName = null) : Winter\Storm\Database\Relations\AttachOne

Inherited from Model

Define an attachment one-to-one relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$isPublic
boolean
$localKey
mixed
$relationName
mixed
Returns

public attributesToArray () : array

Inherited from Model

Convert the model's attributes to an array.

Returns
array

public belongsTo ($related, $foreignKey = null, $parentKey = null, $relationName = null) : Winter\Storm\Database\Relations\BelongsTo

Inherited from Model

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.

Parameters
Property Description
$related
mixed
$foreignKey
mixed
$parentKey
mixed
$relationName
mixed
Returns

public belongsToMany ($related, $table = null, $primaryKey = null, $foreignKey = null, $parentKey = null, $relatedKey = null, $relationName = null) : Winter\Storm\Database\Relations\BelongsToMany

Inherited from Model

Define a many-to-many relationship.

This code is almost a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$table
mixed
$primaryKey
mixed
$foreignKey
mixed
$parentKey
mixed
$relatedKey
mixed
$relationName
mixed
Returns

public bindDeferred (string $relation, Illuminate\Database\Eloquent\Model $record, string $sessionKey, array $pivotData = []) : Winter\Storm\Database\Models\DeferredBinding

Inherited from Model

Bind a deferred relationship to the supplied record.

Parameters
Property Description
$relation
string
$record
Illuminate\Database\Eloquent\Model
$sessionKey
string
$pivotData
array
Returns
Winter\Storm\Database\Models\DeferredBinding

public bindEvent (string | Closure | QueuedClosure $event, mixed $callback = null, integer $priority) : self

Inherited from Model

Create a new event binding.

Parameters
Property Description
$event
string | Closure | QueuedClosure
$callback
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
Returns
self

public bindEventOnce (string | Closure | QueuedClosure $event, QueuedClosure | Closure | null $callback = null) : self

Inherited from Model

Create a new event binding that fires once only

Parameters
Property Description
$event
string | Closure | QueuedClosure
$callback
QueuedClosure | Closure | null

When a Closure or QueuedClosure is provided as the first parameter this parameter can be omitted

Returns
self

public static bootPurgeable () : void

Inherited from Model

Boot the purgeable trait for a model.

Returns
void

public static bootSortable () : void

Inherited from Sortable

Boot the sortable trait for this model.

Returns
void

public cancelDeferred (string $sessionKey) : void

Inherited from Model

Cancel all deferred bindings to this model.

Parameters
Property Description
$sessionKey
string
Returns
void

public static clearExtendedClasses () : void

Inherited from Model

Clear the list of extended classes so they will be re-extended.

Returns
void

public commitDeferred (string $sessionKey) : void

Inherited from Model

Commit all deferred bindings to this model.

Parameters
Property Description
$sessionKey
string
Returns
void

public static create (array $attributes = [], string $sessionKey = null) : Illuminate\Database\Eloquent\Model | static

Inherited from Model

Save a new model and return the instance.

Parameters
Property Description
$attributes
array
$sessionKey
string
Returns
Illuminate\Database\Eloquent\Model | static

public extendClassWith (string $extensionName) : void

Inherited from Model

Dynamically extend a class with a specified behavior

Parameters
Property Description
$extensionName
string
Returns
void

public extendableCall (string $name, array $params = null) : mixed

Inherited from Model

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
Parameters
Property Description
$name
string
$params
array
Returns
mixed

public static extendableCallStatic (string $name, array $params = null) : mixed

Inherited from Model

Magic method for __callStatic()

Parameters
Property Description
$name
string
$params
array
Returns
mixed

public extendableConstruct ()

Inherited from Model

This method should be called as part of the constructor.

Returns
mixed

public static extendableExtendCallback (callable $callback, boolean $scoped = false, $outerScope = null) : void

Inherited from Model

Helper method for ::extend() static method.

Parameters
Property Description
$callback
callable
$scoped
boolean
$outerScope
mixed
Returns
void

public extendableGet (string $name) : mixed | null

Inherited from Model

Magic method for __get()

Parameters
Property Description
$name
string
Returns
mixed | null

public extendableSet (string $name, mixed $value) : void

Inherited from Model

Magic method for __set()

Parameters
Property Description
$name
string
$value
mixed
Returns
void

public static fetched (Closure | string $callback) : void

Inherited from Model

Create a new native event for handling afterFetch().

Parameters
Property Description
$callback
Closure | string
Returns
void

public static fetching (Closure | string $callback) : void

Inherited from Model

Create a new native event for handling beforeFetch().

Parameters
Property Description
$callback
Closure | string
Returns
void

public fireEvent (string $event, array $params = [], boolean $halt = false) : array | mixed | null

Inherited from Model

Fire an event and call the listeners.

Parameters
Property Description
$event
string

Event name

$params
array

Event parameters

$halt
boolean

Halt after first non-null result

Returns
array | mixed | null

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

Inherited from Model

Flush the memory cache.

Returns
void

public static flushEventListeners () : void

Inherited from Model

Remove all of the event listeners for the model Also flush registry of models that had events booted Allows painless unit testing.

Returns
void

public freshTimestamp () : Illuminate\Support\Carbon

Inherited from Model

Get a fresh timestamp for the model.

Returns
Illuminate\Support\Carbon

public fromDateTime (DateTime | int | null $value = null) : string | null

Inherited from Model

Convert a DateTime to a storable string.

Parameters
Property Description
$value
DateTime | int | null
Returns
string | null

public getAttribute (string $key) : mixed

Inherited from Model

Get an attribute from the model.

Overrides {@link Eloquent} to support loading from property-defined relations.

Parameters
Property Description
$key
string
Returns
mixed

public getAttributeValue (string $key) : mixed

Inherited from Model

Get a plain attribute (not a relationship).

Parameters
Property Description
$key
string
Returns
mixed

public getClassExtension (string $name) : mixed

Inherited from Model

Returns a behavior object from an extendable class, example:

$this->getClassExtension('Backend.Behaviors.FormController')

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
mixed

public getClassMethods () : array

Inherited from Model

Get a list of class methods, extension equivalent of get_class_methods()

Returns
array

public getDynamicProperties () : array

Inherited from Model

Returns all dynamic properties and their values

Returns
array

['property' => 'value']

public getJsonable () : array

Inherited from Model

Get the jsonable attributes name

Returns
array

public getObservableEvents () : array

Inherited from Model

Get the observable event names.

Returns
array

public getOriginalPurgeValue ($attribute)

Inherited from Model

Returns the original values of any purged attributes.

Parameters
Property Description
$attribute
mixed
Returns
mixed

public getOriginalPurgeValues ()

Inherited from Model

Returns the original values of any purged attributes.

Returns
mixed

public getPurgeableAttributes ()

Inherited from Model

Returns a collection of fields that will be hashed.

Returns
mixed

public getRelationDefinition (string $name) : array | null

Inherited from Model

Returns relationship details from a supplied name.

Parameters
Property Description
$name
string

Relation name

Returns
array | null

public getRelationDefinitions () : array

Inherited from Model

Returns relationship details for all relations defined on this model.

Returns
array

public getRelationType (string $name) : string | null

Inherited from Model

Returns a relationship type based on a supplied name.

Parameters
Property Description
$name
string
Returns
string | null

public getRelationTypeDefinition (string $type, string $name) : string | null

Inherited from Model

Returns the given relation definition.

Parameters
Property Description
$type
string

Relation type

$name
string

Relation name

Returns
string | null

public getRelationTypeDefinitions (string $type) : array | string | null

Inherited from Model

Returns all defined relations of given type.

Parameters
Property Description
$type
string

Relation type

Returns
array | string | null

public getRelationValue ($relationName)

Inherited from Model

Returns a relation key value(s), not as an object.

Parameters
Property Description
$relationName
mixed
Returns
mixed

public getSortOrderColumn () : string

Inherited from Sortable

Get the name of the "sort order" column.

Returns
string

public hasGetMutator (string $key) : bool

Inherited from Model

Determine if a get mutator exists for an attribute.

Parameters
Property Description
$key
string
Returns
bool

public hasMany ($related, $primaryKey = null, $localKey = null, $relationName = null) : Winter\Storm\Database\Relations\HasMany

Inherited from Model

Define a one-to-many relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$primaryKey
mixed
$localKey
mixed
$relationName
mixed
Returns

public hasManyThrough ($related, $through, $primaryKey = null, $throughKey = null, $localKey = null, $secondLocalKey = null, $relationName = null) : Winter\Storm\Database\Relations\HasManyThrough

Inherited from Model

Define a has-many-through relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$through
mixed
$primaryKey
mixed
$throughKey
mixed
$localKey
mixed
$secondLocalKey
mixed
$relationName
mixed
Returns

public hasOne ($related, $primaryKey = null, $localKey = null, $relationName = null) : Winter\Storm\Database\Relations\HasOne

Inherited from Model

Define a one-to-one relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$primaryKey
mixed
$localKey
mixed
$relationName
mixed
Returns

public hasOneThrough ($related, $through, $primaryKey = null, $throughKey = null, $localKey = null, $secondLocalKey = null, $relationName = null) : Winter\Storm\Database\Relations\HasOneThrough

Inherited from Model

Define a has-one-through relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$through
mixed
$primaryKey
mixed
$throughKey
mixed
$localKey
mixed
$secondLocalKey
mixed
$relationName
mixed
Returns

public hasRelation (string $name) : bool

Inherited from Model

Checks if model has a relationship by supplied name.

Parameters
Property Description
$name
string

Relation name

Returns
bool

public hasSetMutator (string $key) : bool

Inherited from Model

Determine if a set mutator exists for an attribute.

Parameters
Property Description
$key
string
Returns
bool

public isClassExtendedWith (string $name) : bool

Inherited from Model

Check if extendable class is extended with a behavior object

Parameters
Property Description
$name
string

Fully qualified behavior name

Returns
bool

public isDeferrable (string $relationName) : bool

Inherited from Model

Returns true if a relation exists and can be deferred.

Parameters
Property Description
$relationName
string
Returns
bool

public isGuarded (string $key) : bool

Inherited from Model

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.

Parameters
Property Description
$key
string
Returns
bool

public isJsonable ($key) : bool

Inherited from Model

Checks if an attribute is jsonable or not.

Parameters
Property Description
$key
mixed
Returns
bool

public isRelationPushable (string $name) : bool

Inherited from Model

Determines whether the specified relation should be saved when push() is called instead of save() on the model. Default: true.

Parameters
Property Description
$name
string

Relation name

Returns
bool

public jsonable (array $jsonable) : $this

Inherited from Model

Set the jsonable attributes for the model.

Parameters
Property Description
$jsonable
array
Returns
$this

public static make (array $attributes = []) : Illuminate\Database\Eloquent\Model | static

Inherited from Model

Create a new model and return the instance.

Parameters
Property Description
$attributes
array
Returns
Illuminate\Database\Eloquent\Model | static

public makeRelation (string $name) : Winter\Storm\Database\Model | null

Inherited from Model

Returns a new instance of a related model

Parameters
Property Description
$name
string
Returns
Winter\Storm\Database\Model | null

public methodExists (string $name) : bool

Inherited from Model

Checks if a method exists, extension equivalent of method_exists()

Parameters
Property Description
$name
string
Returns
bool

public morphMany ($related, $name, $type = null, $id = null, $localKey = null, $relationName = null) : Winter\Storm\Database\Relations\MorphMany

Inherited from Model

Define a polymorphic one-to-many relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$name
mixed
$type
mixed
$id
mixed
$localKey
mixed
$relationName
mixed
Returns

public morphOne ($related, $name, $type = null, $id = null, $localKey = null, $relationName = null) : Winter\Storm\Database\Relations\MorphOne

Inherited from Model

Define a polymorphic one-to-one relationship.

This code is a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$name
mixed
$type
mixed
$id
mixed
$localKey
mixed
$relationName
mixed
Returns

public morphTo ($name = null, $type = null, $id = null, $ownerKey = null) : Winter\Storm\Database\Relations\MorphTo

Inherited from Model

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.

Parameters
Property Description
$name
mixed
$type
mixed
$id
mixed
$ownerKey
mixed
Returns

public morphToMany ($related, $name, $table = null, $primaryKey = null, $foreignKey = null, $parentKey = null, $relatedKey = null, boolean $inverse = false, $relationName = null) : Winter\Storm\Database\Relations\MorphToMany

Inherited from Model

Define a polymorphic many-to-many relationship.

This code is almost a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$name
mixed
$table
mixed
$primaryKey
mixed
$foreignKey
mixed
$parentKey
mixed
$relatedKey
mixed
$inverse
boolean
$relationName
mixed
Returns

public morphedByMany ($related, $name, $table = null, $primaryKey = null, $foreignKey = null, $parentKey = null, $relatedKey = null, $relationName = null) : Winter\Storm\Database\Relations\MorphToMany

Inherited from Model

Define a polymorphic many-to-many inverse relationship.

This code is almost a duplicate of Eloquent but uses a Storm relation class.

Parameters
Property Description
$related
mixed
$name
mixed
$table
mixed
$primaryKey
mixed
$foreignKey
mixed
$parentKey
mixed
$relatedKey
mixed
$relationName
mixed
Returns

public newCollection (array $models = []) : Winter\Storm\Database\Collection

Inherited from Model

Create a new Model Collection instance.

Parameters
Property Description
$models
array
Returns

public newEloquentBuilder (Winter\Storm\Database\QueryBuilder $query) : Winter\Storm\Database\Builder

Inherited from Model

Create a new Eloquent query builder for the model.

Parameters
Returns

public newFromBuilder (array $attributes = [], $connection = null) : Illuminate\Database\Eloquent\Model | static

Inherited from Model

Create a new model instance that is existing.

Parameters
Property Description
$attributes
array
$connection
mixed
Returns
Illuminate\Database\Eloquent\Model | static

public newPivot (Illuminate\Database\Eloquent\Model $parent, array $attributes, string $table, bool $exists, string | null $using = null) : Winter\Storm\Database\Pivot

Inherited from Model

Create a generic pivot model instance.

Parameters
Property Description
$parent
Illuminate\Database\Eloquent\Model
$attributes
array
$table
string
$exists
bool
$using
string | null
Returns

public newRelationPivot (string $relationName, Winter\Storm\Database\Model $parent, array $attributes, string $table, bool $exists) : Winter\Storm\Database\Pivot | null

Inherited from Model

Create a pivot model instance specific to a relation.

Parameters
Property Description
$relationName
string
$parent
$attributes
array
$table
string
$exists
bool
Returns

public offsetExists (mixed $offset) : bool

Inherited from Model

This a custom piece of logic specifically to satisfy Twig's desire to return a relation object instead of loading the related model.

Parameters
Property Description
$offset
mixed
Returns
bool

public propertyExists (string $name) : bool

Inherited from Model

Checks if a property exists, extension equivalent of property_exists()

Parameters
Property Description
$name
string
Returns
bool

public purgeAttributes (array | string $attributesToPurge = null) : array

Inherited from Model

Removes purged attributes from the dataset, used before saving.

Parameters
Property Description
$attributesToPurge
array | string

Attribute(s) to purge, if unspecified, $purgable property is used

Returns
array

Current attribute set

public push (array $options = [], string | null $sessionKey = null) : bool

Inherited from Model

Save the model and all of its relationships.

Parameters
Property Description
$options
array
$sessionKey
string | null
Returns
bool

public reload () : Illuminate\Database\Eloquent\Model | static

Inherited from Model

Reloads the model attributes from the database.

Returns
Illuminate\Database\Eloquent\Model | static

public reloadRelations (string $relationName = null) : void

Inherited from Model

Reloads the model relationship cache.

Parameters
Property Description
$relationName
string
Returns
void

public restorePurgedValues ()

Inherited from Model

Restores the original values of any purged attributes.

Returns
mixed

public save (array $options = [], string | null $sessionKey = null) : bool

Inherited from Model

Save the model to the database.

Parameters
Property Description
$options
array
$sessionKey
string | null
Returns
bool

public setAttribute (string $key, mixed $value) : mixed | null

Inherited from Model

Set a given attribute on the model.

Parameters
Property Description
$key
string
$value
mixed
Returns
mixed | null

public setSortableOrder (mixed $itemIds, array $itemOrders = null) : void

Inherited from Sortable

Sets the sort order of records to the specified orders. If the orders is undefined, the record identifier is used.

Parameters
Property Description
$itemIds
mixed
$itemOrders
array
Returns
void

public unbindDeferred (string $relation, Illuminate\Database\Eloquent\Model $record, string $sessionKey) : Winter\Storm\Database\Models\DeferredBinding

Inherited from Model

Unbind a deferred relationship to the supplied record.

Parameters
Property Description
$relation
string
$record
Illuminate\Database\Eloquent\Model
$sessionKey
string
Returns
Winter\Storm\Database\Models\DeferredBinding

public unbindEvent (string | array | object $event = null) : self

Inherited from Model

Destroys an event binding.

Parameters
Property Description
$event
string | array | object

Event to destroy

Returns
self

protected addRelation (string $type, string $name, array $config) : void

Inherited from Model

Dynamically add the provided relationship configuration to the local properties

Parameters
Property Description
$type
string
$name
string
$config
array
Returns
void

protected afterCreate ()

Inherited from Model

Handle the "created" model event

Returns
mixed

protected afterFetch ()

Inherited from Model

Handle the "fetched" model event

Returns
mixed

protected afterSave ()

Inherited from Model

Handle the "saved" model event

Returns
mixed

protected afterUpdate ()

Inherited from Model

Handle the "updated" model event

Returns
mixed

protected asDateTime (mixed $value) : Carbon\Carbon

Inherited from Model

Return a timestamp as DateTime object.

Parameters
Property Description
$value
mixed
Returns
Carbon\Carbon

protected beforeCreate ()

Inherited from Model

Handle the "creating" model event

Returns
mixed

protected beforeDelete ()

Inherited from Model

Handle the "deleting" model event

Returns
mixed

protected beforeFetch ()

Inherited from Model

Handle the "fetching" model event

Returns
mixed

protected beforeUpdate ()

Inherited from Model

Handle the "updating" model event

Returns
mixed

protected bootNicerEvents ()

Inherited from Model

Bind some nicer events to this model, in the format of method overrides.

Returns
mixed

protected commitDeferredAfter (string $sessionKey) : void

Inherited from Model

Internally used method to commit all deferred bindings after saving.

Parameters
Property Description
$sessionKey
string
Returns
void

protected commitDeferredBefore (string $sessionKey) : void

Inherited from Model

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.

Parameters
Property Description
$sessionKey
string
Returns
void

protected commitDeferredOfType (string $sessionKey, $include = null, $exclude = null) : void

Inherited from Model

Internal method for committing deferred relations.

Parameters
Property Description
$sessionKey
string
$include
mixed
$exclude
mixed
Returns
void

protected emitterEventSortEvents (string $eventName) : void

Inherited from Model

Sort the listeners for a given event by priority.

Parameters
Property Description
$eventName
string
Returns
void

protected extendableIsAccessible (mixed $class, string $propertyName) : bool

Inherited from Model

Checks if a property is accessible, property equivalent of is_callable()

Parameters
Property Description
$class
mixed
$propertyName
string
Returns
bool

protected extensionExtractMethods (string $extensionName, object $extensionObject) : void

Inherited from Model

Extracts the available methods from a behavior and adds it to the list of callable methods.

Parameters
Property Description
$extensionName
string
$extensionObject
object
Returns
void

protected extensionGetClassLoader () : Winter\Storm\Support\ClassLoader | null

Inherited from Model

Gets the class loader

Returns
Winter\Storm\Support\ClassLoader | null

protected extensionNormalizeClassName (string $name) : string

Inherited from Model

Normalizes the provided extension name allowing for the ClassLoader to inject aliased classes

Parameters
Property Description
$name
string
Returns
string

protected getDeferrableRelationTypes () : array

Inherited from Model

Returns all possible relation types that can be deferred.

Returns
array

protected getDeferredBindingRecords (string $sessionKey) : Winter\Storm\Database\Collection

Inherited from Model

Returns any outstanding binding records for this model.

Parameters
Property Description
$sessionKey
string
Returns
Winter\Storm\Database\Collection

protected getMorphs (string $name, string | null $type = null, string | null $id = null) : array

Inherited from Model

Get the polymorphic relationship columns.

Parameters
Property Description
$name
string
$type
string | null
$id
string | null
Returns
array

protected getRelationCaller ()

Inherited from Model

Finds the calling function name from the stack trace.

Returns
mixed

protected getRelationDefaults (string $type) : array

Inherited from Model

Returns default relation arguments for a given type.

Parameters
Property Description
$type
string

Relation type

Returns
array

protected handleRelation (string $relationName) : Illuminate\Database\Eloquent\Relations\Relation

Inherited from Model

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.

Parameters
Property Description
$relationName
string

the relation key, camel-case version

Returns
Illuminate\Database\Eloquent\Relations\Relation

protected morphEagerTo (string $name, string $type, string $id, string $ownerKey) : Winter\Storm\Database\Relations\MorphTo

Inherited from Model

Define a polymorphic, inverse one-to-one or many relationship.

Parameters
Property Description
$name
string
$type
string
$id
string
$ownerKey
string
Returns

protected morphInstanceTo (string $target, string $name, string $type, string $id, string | null $ownerKey = null) : Winter\Storm\Database\Relations\MorphTo

Inherited from Model

Define a polymorphic, inverse one-to-one or many relationship.

Parameters
Property Description
$target
string
$name
string
$type
string
$id
string
$ownerKey
string | null
Returns

protected newBaseQueryBuilder () : Winter\Storm\Database\QueryBuilder

Inherited from Model

Get a new query builder instance for the connection.

Returns

protected parseEventAndPayload (mixed $event, mixed $payload = null) : array

Inherited from Model

Parse the given event and payload and prepare them for dispatching.

Parameters
Property Description
$event
mixed
$payload
mixed
Returns
array

protected performDeleteOnModel () : void

Inherited from Model

Perform the actual delete query on this model instance.

Returns
void

protected performDeleteOnRelations () : void

Inherited from Model

Locates relations with delete flag and cascades the delete event.

Returns
void

protected saveInternal (array $options = []) : bool

Inherited from Model

Save the model to the database. Is used by {@link save()} and {@link forceSave()}.

Parameters
Property Description
$options
array
Returns
bool

protected setRelationValue ($relationName, $value)

Inherited from Model

Sets a relation value directly from its attribute.

Parameters
Property Description
$relationName
mixed
$value
mixed
Returns
mixed

protected validateRelationArgs ($relationName, $optional, array $required = [])

Inherited from Model

Validate relation supplied arguments.

Parameters
Property Description
$relationName
mixed
$optional
mixed
$required
array
Returns
mixed
Copyright © 2024 Winter CMS