class Block extends Model (View source)

Traits

Properties

protected $cropParamsKeys from  HasMedias
protected $presenterInstance from  HasPresenter
protected $relatedCache from  HasRelated
$timestamps
protected $fillable
protected $casts
protected $with

Methods

static void
bootHasMedias()

No description

MorphToMany
medias()

Defines the many-to-many relationship for media objects.

bool
hasImage(string $role, string $crop = "default")

Checks if an image has been attached for a role and crop.

string|null
image(string $role, string $crop = "default", array $params = [], bool $has_fallback = false, bool $cms = false, Media|null $media = null)

Returns the URL of the attached image for a role and crop.

array
images(string $role, string $crop = "default", array $params = [])

Returns an array of URLs of all attached images for a role and crop.

array
imagesWithCrops(string $role, array $params = [])

Returns an array of URLs of all attached images for a role, including all crops.

array
imageAsArray(string $role, string $crop = "default", array $params = [], Media|null $media = null)

Returns an array of meta information for the image attached for a role and crop.

array
imagesAsArrays(string $role, string $crop = "default", array $params = [])

Returns an array of meta information for all images attached for a role and crop.

array
imagesAsArraysWithCrops(string $role, array $params = [])

Returns an array of meta information for all images attached for a role, including all crops.

string
imageAltText(string $role, Media|null $media = null)

Returns the alt text of the image attached for a role.

string
imageCaption(string $role, Media|null $media = null)

Returns the caption of the image attached for a role.

string
imageVideo(string $role, Media|null $media = null)

Returns the video URL of the image attached for a role.

Media|null
imageObject(string $role, string $crop = "default")

Returns the media object attached for a role and crop.

string|null
lowQualityImagePlaceholder(string $role, string $crop = "default", array $params = [], bool $has_fallback = false)

Returns the LQIP base64 encoded string for a role.

string|null
socialImage(string $role, string $crop = "default", array $params = [], bool $has_fallback = false)

Returns the URL of the social image for a role and crop.

string
cmsImage(string $role, string $crop = "default", array $params = [])

Returns the URL of the CMS image for a role and crop.

string
defaultCmsImage(array $params = [])

Returns the URL of the default CMS image for this model.

Collection
imageObjects(string $role, string $crop = "default")

Returns the media objects associated with a role and crop.

MorphToMany
files()

Defines the many-to-many relationship for file objects.

from  HasFiles
string|null
file(string $role, string|null $locale = null, File|null $file = null)

Returns the URL of the attached file for a role.

from  HasFiles
array
filesList(string $role, string|null $locale = null)

Returns an array of URLs of all attached files for a role.

from  HasFiles
File|null
fileObject(string $role, string|null $locale = null)

Returns the file object attached for a role.

from  HasFiles
object
present(string $presenter = 'presenter')

No description

object
presentAdmin()

No description

$this
setPresenter(string $presenter, string $presenterProperty = 'presenter')

No description

$this
setPresenterAdmin(string $presenter)

No description

MorphMany
relatedItems()

Defines the one-to-many relationship for related items.

Collection
getRelated(string $browser_name)

Returns the related items for a browser field.

Collection
loadRelated(string $browser_name)

Eager load related items for a browser field.

void
saveRelated(array $items, string $browser_name)

Attach items to the model for a browser field.

void
clearRelated($browserName)

No description

void
clearAllRelated()

No description

scopeEditor($query, $name = 'default')

No description

blockable()

No description

children()

No description

input($name)

No description

translatedInput($name, $forceLocale = null)

No description

browserIds($name)

No description

checkbox($name)

No description

getPresenterAttribute()

No description

getTable()

No description

Details

static void bootHasMedias()

No description

Return Value

void

MorphToMany medias()

Defines the many-to-many relationship for media objects.

Return Value

MorphToMany

bool hasImage(string $role, string $crop = "default")

Checks if an image has been attached for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

Return Value

bool

string|null image(string $role, string $crop = "default", array $params = [], bool $has_fallback = false, bool $cms = false, Media|null $media = null)

Returns the URL of the attached image for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

bool $has_fallback

Indicate that you can provide a fallback. Will return null instead of the default image fallback.

bool $cms

Indicate that you are displaying this image in the CMS views.

Media|null $media

Provide a media object if you already retrieved one to prevent more SQL queries.

Return Value

string|null

array images(string $role, string $crop = "default", array $params = [])

Returns an array of URLs of all attached images for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

Return Value

array

array imagesWithCrops(string $role, array $params = [])

Returns an array of URLs of all attached images for a role, including all crops.

Parameters

string $role

Role name.

array $params

Parameters compatible with the current image service, like w or h.

Return Value

array

array imageAsArray(string $role, string $crop = "default", array $params = [], Media|null $media = null)

Returns an array of meta information for the image attached for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

Media|null $media

Provide a media object if you already retrieved one to prevent more SQL queries.

Return Value

array

array imagesAsArrays(string $role, string $crop = "default", array $params = [])

Returns an array of meta information for all images attached for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

Return Value

array

array imagesAsArraysWithCrops(string $role, array $params = [])

Returns an array of meta information for all images attached for a role, including all crops.

Parameters

string $role

Role name.

array $params

Parameters compatible with the current image service, like w or h.

Return Value

array

string imageAltText(string $role, Media|null $media = null)

Returns the alt text of the image attached for a role.

Parameters

string $role

Role name.

Media|null $media

Provide a media object if you already retrieved one to prevent more SQL queries.

Return Value

string

string imageCaption(string $role, Media|null $media = null)

Returns the caption of the image attached for a role.

Parameters

string $role

Role name.

Media|null $media

Provide a media object if you already retrieved one to prevent more SQL queries.

Return Value

string

string imageVideo(string $role, Media|null $media = null)

Returns the video URL of the image attached for a role.

Parameters

string $role

Role name.

Media|null $media

Provide a media object if you already retrieved one to prevent more SQL queries.

Return Value

string

Media|null imageObject(string $role, string $crop = "default")

Returns the media object attached for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

Return Value

Media|null

string|null lowQualityImagePlaceholder(string $role, string $crop = "default", array $params = [], bool $has_fallback = false)

Returns the LQIP base64 encoded string for a role.

Use this in conjunction with the RefreshLQIP Artisan command.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

bool $has_fallback

Indicate that you can provide a fallback. Will return null instead of the default image fallback.

Return Value

string|null

See also

RefreshLQIP

string|null socialImage(string $role, string $crop = "default", array $params = [], bool $has_fallback = false)

Returns the URL of the social image for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

bool $has_fallback

Indicate that you can provide a fallback. Will return null instead of the default image fallback.

Return Value

string|null

string cmsImage(string $role, string $crop = "default", array $params = [])

Returns the URL of the CMS image for a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

array $params

Parameters compatible with the current image service, like w or h.

Return Value

string

string defaultCmsImage(array $params = [])

Returns the URL of the default CMS image for this model.

Parameters

array $params

Parameters compatible with the current image service, like w or h.

Return Value

string

Collection imageObjects(string $role, string $crop = "default")

Returns the media objects associated with a role and crop.

Parameters

string $role

Role name.

string $crop

Crop name.

Return Value

Collection

MorphToMany files()

Defines the many-to-many relationship for file objects.

Return Value

MorphToMany

string|null file(string $role, string|null $locale = null, File|null $file = null)

Returns the URL of the attached file for a role.

Parameters

string $role

Role name.

string|null $locale

Locale of the file if your site has multiple languages.

File|null $file

Provide a file object if you already retrieved one to prevent more SQL queries.

Return Value

string|null

array filesList(string $role, string|null $locale = null)

Returns an array of URLs of all attached files for a role.

Parameters

string $role

Role name.

string|null $locale

Locale of the file if your site has multiple languages.

Return Value

array

File|null fileObject(string $role, string|null $locale = null)

Returns the file object attached for a role.

Parameters

string $role

Role name.

string|null $locale

Locale of the file if your site has multiple languages.

Return Value

File|null

object present(string $presenter = 'presenter')

No description

Parameters

string $presenter

Return Value

object

object presentAdmin()

No description

Return Value

object

$this setPresenter(string $presenter, string $presenterProperty = 'presenter')

No description

Parameters

string $presenter
string $presenterProperty

Return Value

$this

$this setPresenterAdmin(string $presenter)

No description

Parameters

string $presenter

Return Value

$this

MorphMany relatedItems()

Defines the one-to-many relationship for related items.

Return Value

MorphMany

Collection getRelated(string $browser_name)

Returns the related items for a browser field.

Parameters

string $browser_name

Return Value

Collection

Collection loadRelated(string $browser_name)

Eager load related items for a browser field.

Parameters

string $browser_name

Return Value

Collection

void saveRelated(array $items, string $browser_name)

Attach items to the model for a browser field.

Parameters

array $items
string $browser_name

Return Value

void

void clearRelated($browserName)

No description

Parameters

$browserName

Return Value

void

void clearAllRelated()

No description

Return Value

void

scopeEditor($query, $name = 'default')

No description

Parameters

$query
$name

blockable()

No description

children()

No description

input($name)

No description

Parameters

$name

translatedInput($name, $forceLocale = null)

No description

Parameters

$name
$forceLocale

browserIds($name)

No description

Parameters

$name

checkbox($name)

No description

Parameters

$name

getPresenterAttribute()

No description

getTable()

No description