Resource
abstract class Resource implements AppendableData, BaseData, Castable, EmptyData, IncludeableData, ResponsableData, TransformableData, WrappableData
Traits
Properties
| protected array | $_additional | from AppendableData | |
| protected PartialsDefinition|false|null | $partialDefinitions | Null before defaults are inspected, false when they are empty, or the mutable definition store. |
from IncludeableData |
| protected Wrap|null | $wrap | from WrappableData |
Methods
Add top-level data to the response.
Get the request caster for the data object.
Collect data objects.
Get the Eloquent caster for the data object.
Create an empty representation of the data class.
Get the partial definition store.
Include properties for the next transformation.
Include properties for every transformation.
Exclude lazy properties for the next transformation.
Exclude lazy properties for every transformation.
Keep only properties for the next transformation.
Keep only properties for every transformation.
Exclude properties for the next transformation.
Exclude properties for every transformation.
Include a property when the condition passes.
Exclude a lazy property when the condition passes.
Exclude a property when the condition passes.
Determine whether this object has partial definitions.
Get the JSON serialization options for the resource response.
Get the request properties that may be included.
Get the request properties that may be excluded.
Get the request properties allowed by an only selection.
Get the request properties allowed by an except selection.
Get original collection items without transforming or enumerating them twice.
Transform the data object to an array.
Convert the data object to its JSON representation.
Details
in
AppendableData at line 16
array
with()
Get the additional data defined by the data object.
in
AppendableData at line 24
AppendableData
additional(array $additional)
Add top-level data to the response.
in
AppendableData at line 34
array
getAdditionalData()
Get the resolved additional response data.
in
RequestCastableData at line 18
static CastsRequestInput
castRequestUsing(array $arguments)
Get the request caster for the data object.
in
BaseData at line 37
static BaseData|null
optional(mixed ...$payloads)
Create an optional data object.
in
BaseData at line 132
static array|DataCollection|PaginatedDataCollection|CursorPaginatedDataCollection|Enumerable|AbstractPaginator|Paginator|AbstractCursorPaginator|CursorPaginator|LazyCollection|Collection
collect(mixed $items, string|null $into = null)
Collect data objects.
Contract-typed sources retain every possible rebuildable runtime shape.
in
BaseData at line 145
static CreationContextFactory
factory()
Create a fresh data construction factory.
in
BaseData at line 158
static array
normalizers()
Get the class-owned data normalizers.
in
BaseData at line 168
static BaseData
newInstance(Request $request)
Create a data object from the current request.
in
EloquentCastableData at line 16
static CastsAttributes|CastsInboundAttributes|string
castUsing(array $arguments)
Get the Eloquent caster for the data object.
in
EmptyData at line 16
static array
empty(array $extra = [], mixed $replaceNullValuesWith = null, array|null $except = null, array|null $only = null)
Create an empty representation of the data class.
in
ForwardsToPartialsDefinition at line 14
abstract protected PartialsDefinition
getPartialsDefinition()
Get the partial definition store.
in
ForwardsToPartialsDefinition at line 19
ForwardsToPartialsDefinition
include(string ...$includes)
Include properties for the next transformation.
in
ForwardsToPartialsDefinition at line 31
ForwardsToPartialsDefinition
includePermanently(string ...$includes)
Include properties for every transformation.
in
ForwardsToPartialsDefinition at line 43
ForwardsToPartialsDefinition
exclude(string ...$excludes)
Exclude lazy properties for the next transformation.
in
ForwardsToPartialsDefinition at line 55
ForwardsToPartialsDefinition
excludePermanently(string ...$excludes)
Exclude lazy properties for every transformation.
in
ForwardsToPartialsDefinition at line 67
ForwardsToPartialsDefinition
only(string ...$only)
Keep only properties for the next transformation.
in
ForwardsToPartialsDefinition at line 79
ForwardsToPartialsDefinition
onlyPermanently(string ...$only)
Keep only properties for every transformation.
in
ForwardsToPartialsDefinition at line 91
ForwardsToPartialsDefinition
except(string ...$except)
Exclude properties for the next transformation.
in
ForwardsToPartialsDefinition at line 103
ForwardsToPartialsDefinition
exceptPermanently(string ...$except)
Exclude properties for every transformation.
in
ForwardsToPartialsDefinition at line 115
ForwardsToPartialsDefinition
includeWhen(string $include, bool|Closure $condition, bool $permanent = false)
Include a property when the condition passes.
in
ForwardsToPartialsDefinition at line 132
ForwardsToPartialsDefinition
excludeWhen(string $exclude, bool|Closure $condition, bool $permanent = false)
Exclude a lazy property when the condition passes.
in
ForwardsToPartialsDefinition at line 149
ForwardsToPartialsDefinition
onlyWhen(string $only, bool|Closure $condition, bool $permanent = false)
Keep only a property when the condition passes.
in
ForwardsToPartialsDefinition at line 166
ForwardsToPartialsDefinition
exceptWhen(string $except, bool|Closure $condition, bool $permanent = false)
Exclude a property when the condition passes.
in
IncludeableData at line 24
bool
hasPartialsDefinition()
Determine whether this object has partial definitions.
in
IncludeableData at line 88
protected array
includeProperties()
Get class-owned permanent include definitions.
in
IncludeableData at line 96
protected array
excludeProperties()
Get class-owned permanent exclude definitions.
in
IncludeableData at line 104
protected array
onlyProperties()
Get class-owned permanent only definitions.
in
IncludeableData at line 112
protected array
exceptProperties()
Get class-owned permanent except definitions.
in
ResponsableData at line 28
JsonResponse
toResponse(Request $request)
Create an HTTP response that represents the data object.
in
ResponsableData at line 67
static int
jsonOptions()
Get the JSON serialization options for the resource response.
in
ResponsableData at line 75
void
withResponse(Request $request, JsonResponse $response)
Customize the outgoing resource response.
in
ResponsableData at line 82
static array|null
allowedRequestIncludes()
Get the request properties that may be included.
in
ResponsableData at line 90
static array|null
allowedRequestExcludes()
Get the request properties that may be excluded.
in
ResponsableData at line 98
static array|null
allowedRequestOnly()
Get the request properties allowed by an only selection.
in
ResponsableData at line 106
static array|null
allowedRequestExcept()
Get the request properties allowed by an except selection.
in
ResponsableData at line 116
protected Collection
responseItems(BaseDataCollectable $data)
Get original collection items without transforming or enumerating them twice.
in
TransformableData at line 20
array
transform(TransformationContextFactory|TransformationContext|null $transformationContext = null)
Transform the data object to an array.
in
TransformableData at line 38
array
all()
Get all visible properties without transforming their values.
in
TransformableData at line 52
array
toArray()
Get the data object as an array.
in
TransformableData at line 60
string
toJson(int $options = 0)
Convert the data object to its JSON representation.
in
TransformableData at line 70
array
jsonSerialize()
Get the data that should be serialized to JSON.
in
WrappableData at line 17
WrappableData
withoutWrapping()
Disable wrapping for the data object.
in
WrappableData at line 27
WrappableData
wrap(string $key)
Wrap the data object with the given key.
in
WrappableData at line 37
Wrap
getWrap()
Get the current wrapping definition.