PHP Class Plank\Mediable\Media

Author: Sean Fraser ([email protected])
Inheritance: extends Illuminate\Database\Eloquent\Model
Show file Open project: plank/laravel-mediable Class Usage Examples

Protected Properties

Property Type Description
$guarded

Public Methods

Method Description
boot ( )
contents ( ) : string Retrieve the contents of the file.
fileExists ( ) : boolean Check if the file exists on disk.
getAbsolutePath ( ) : string Get the absolute filesystem path to the file.
getBasenameAttribute ( ) : string Retrieve the file extension.
getDiskPath ( ) : string Get the path to the file relative to the root of the disk.
getUrl ( ) : string Get the absolute URL to the media file.
isPubliclyAccessible ( ) : boolean Check if the file is located below the public webroot.
models ( string $class ) : Illuminate\Database\Eloquent\Relations\MorphToMany Retrieve all associated models of given class.
move ( string $destination, string $filename = null ) : void Move the file to a new location on disk.
readableSize ( integer $precision = 1 ) : string Calculate the file size in human readable byte notation.
rename ( $filename ) : void Rename the file in place.
scopeForPathOnDisk ( Builder $q, string $disk, string $path ) : void Query scope finding media at a path relative to a disk.
scopeInDirectory ( Builder $q, string $disk, string $directory, boolean $recursive = false ) : void Query scope for to find media in a particular directory.
scopeInOrUnderDirectory ( Builder $q, string $disk, string $directory ) : void Query scope for finding media in a particular directory or one of its subdirectories.
scopeUnordered ( Builder $q ) : void Query scope to remove the order by clause from the query.
scopeWhereBasename ( Builder $q, string $basename ) : void Query scope for finding media by basename.

Protected Methods

Method Description
getUrlGenerator ( ) : Plank\Mediable\UrlGenerators\UrlGenerator Get a UrlGenerator instance for the media.
handleMediaDeletion ( )
storage ( ) : Illuminate\Contracts\Filesystem\Filesystem Get the filesystem object for this media.

Method Details

boot() public static method

public static boot ( )

contents() public method

Retrieve the contents of the file.
public contents ( ) : string
return string

fileExists() public method

Check if the file exists on disk.
public fileExists ( ) : boolean
return boolean

getAbsolutePath() public method

Get the absolute filesystem path to the file.
public getAbsolutePath ( ) : string
return string

getBasenameAttribute() public method

Retrieve the file extension.
public getBasenameAttribute ( ) : string
return string

getDiskPath() public method

Get the path to the file relative to the root of the disk.
public getDiskPath ( ) : string
return string

getUrl() public method

Get the absolute URL to the media file.
public getUrl ( ) : string
return string

getUrlGenerator() protected method

Get a UrlGenerator instance for the media.
protected getUrlGenerator ( ) : Plank\Mediable\UrlGenerators\UrlGenerator
return Plank\Mediable\UrlGenerators\UrlGenerator

handleMediaDeletion() protected method

protected handleMediaDeletion ( )

isPubliclyAccessible() public method

Check if the file is located below the public webroot.
public isPubliclyAccessible ( ) : boolean
return boolean

models() public method

Retrieve all associated models of given class.
public models ( string $class ) : Illuminate\Database\Eloquent\Relations\MorphToMany
$class string FQCN
return Illuminate\Database\Eloquent\Relations\MorphToMany

move() public method

Will invoke the save() method on the model after the associated file has been moved to prevent synchronization errors
public move ( string $destination, string $filename = null ) : void
$destination string directory relative to disk root
$filename string filename. Do not include extension
return void

readableSize() public method

Calculate the file size in human readable byte notation.
public readableSize ( integer $precision = 1 ) : string
$precision integer (_optional_) Number of decimal places to include.
return string

rename() public method

Rename the file in place.
See also: Plank\Mediable\Media::move()
public rename ( $filename ) : void
return void

scopeForPathOnDisk() public method

Query scope finding media at a path relative to a disk.
public scopeForPathOnDisk ( Builder $q, string $disk, string $path ) : void
$q Illuminate\Database\Eloquent\Builder
$disk string
$path string directory, filename and extension
return void

scopeInDirectory() public method

Query scope for to find media in a particular directory.
public scopeInDirectory ( Builder $q, string $disk, string $directory, boolean $recursive = false ) : void
$q Illuminate\Database\Eloquent\Builder
$disk string Filesystem disk to search in
$directory string Path relative to disk
$recursive boolean (_optional_) If true, will find media in or under the specified directory
return void

scopeInOrUnderDirectory() public method

Query scope for finding media in a particular directory or one of its subdirectories.
public scopeInOrUnderDirectory ( Builder $q, string $disk, string $directory ) : void
$q Illuminate\Database\Eloquent\Builder
$disk string Filesystem disk to search in
$directory string Path relative to disk
return void

scopeUnordered() public method

Query scope to remove the order by clause from the query.
public scopeUnordered ( Builder $q ) : void
$q Illuminate\Database\Eloquent\Builder
return void

scopeWhereBasename() public method

Query scope for finding media by basename.
public scopeWhereBasename ( Builder $q, string $basename ) : void
$q Illuminate\Database\Eloquent\Builder
$basename string filename and extension
return void

storage() protected method

Get the filesystem object for this media.
protected storage ( ) : Illuminate\Contracts\Filesystem\Filesystem
return Illuminate\Contracts\Filesystem\Filesystem

Property Details

$guarded protected property

protected $guarded