\App\Http\ResourcesLoadsAttributesByAuthorization

LoadsAttributesByAuthorization - JSON resource helper trait with helper functions.

Summary

Methods
Properties
Constants
No public methods found
No public properties found
No constants found
getUser()
whenAdmin()
whenLoggedIn()
whenOwned()
getOwnedBy()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getUser()

getUser() : \App\User|null

Get currently authorized user

Returns

\App\User|null

whenAdmin()

whenAdmin(mixed  $value, mixed  $default = null) : \Illuminate\Http\Resources\MissingValue|mixed

Retrieve a value based on whether the user has admin privileges

Parameters

mixed $value
mixed $default

Returns

\Illuminate\Http\Resources\MissingValue|mixed

whenLoggedIn()

whenLoggedIn(mixed  $value, mixed  $default = null) : \Illuminate\Http\Resources\MissingValue|mixed

Retrieve a value based on whether the user is logged in

Parameters

mixed $value
mixed $default

Returns

\Illuminate\Http\Resources\MissingValue|mixed

whenOwned()

whenOwned(mixed  $value, mixed  $default = null) : \Illuminate\Http\Resources\MissingValue|mixed

Retrieve a value based on whether the model is owned by the logged in user

Parameters

mixed $value
mixed $default

Returns

\Illuminate\Http\Resources\MissingValue|mixed

getOwnedBy()

getOwnedBy(\App\User  $user) : boolean

Parameters

\App\User $user

Returns

boolean