class Attribute (View source)

Properties

callable $get

The attribute accessor.

callable $set

The attribute mutator.

bool $withCaching

Indicates if caching is enabled for this attribute.

bool $withObjectCaching

Indicates if caching of objects is enabled for this attribute.

Methods

void
__construct(callable|null $get = null, callable|null $set = null)

Create a new attribute accessor / mutator.

static Attribute
make(callable|null $get = null, callable|null $set = null)

Create a new attribute accessor / mutator.

static Attribute
get(callable $get)

Create a new attribute accessor.

static Attribute
set(callable $set)

Create a new attribute mutator.

withoutObjectCaching()

Disable object caching for the attribute.

shouldCache()

Enable caching for the attribute.

Details

void __construct(callable|null $get = null, callable|null $set = null)

Create a new attribute accessor / mutator.

Parameters

callable|null $get
callable|null $set

Return Value

void

static Attribute make(callable|null $get = null, callable|null $set = null)

Create a new attribute accessor / mutator.

Parameters

callable|null $get
callable|null $set

Return Value

Attribute

static Attribute get(callable $get)

Create a new attribute accessor.

Parameters

callable $get

Return Value

Attribute

static Attribute set(callable $set)

Create a new attribute mutator.

Parameters

callable $set

Return Value

Attribute

Attribute withoutObjectCaching()

Disable object caching for the attribute.

Return Value

Attribute

Attribute shouldCache()

Enable caching for the attribute.

Return Value

Attribute

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.