trait TransformsToResource

Provides the ability to transform a model to a JSON resource.

Methods

toResource(string|null $resourceClass = null)

Create a new resource object for the given resource.

guessResource()

Guess the resource class for the model.

static array
guessResourceName()

Guess the resource class name for the model.

string|null
resolveResourceFromAttribute(string $class)

Get the resource class from the UseResource attribute.

Details

at line 23
JsonResource toResource(string|null $resourceClass = null)

Create a new resource object for the given resource.

Parameters

string|null $resourceClass

Return Value

JsonResource

at line 35
protected JsonResource guessResource()

Guess the resource class for the model.

Return Value

JsonResource

at line 58
static array guessResourceName()

Guess the resource class name for the model.

Return Value

array

at line 88
protected string|null resolveResourceFromAttribute(string $class)

Get the resource class from the UseResource attribute.

Parameters

string $class

Return Value

string|null