Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/RelationController.php
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | class RelationController extends ResourceController | ||||
* Prepare resource statuses for the UI | * Prepare resource statuses for the UI | ||||
* | * | ||||
* @param object $resource Resource object | * @param object $resource Resource object | ||||
* | * | ||||
* @return array Statuses array | * @return array Statuses array | ||||
*/ | */ | ||||
protected static function objectState($resource): array | protected static function objectState($resource): array | ||||
{ | { | ||||
return []; | $state = []; | ||||
$reflect = new \ReflectionClass(get_class($resource)); | |||||
foreach (array_keys($reflect->getConstants()) as $const) { | |||||
if (strpos($const, 'STATUS_') === 0 && $const != 'STATUS_NEW') { | |||||
$method = Str::camel('is_' . strtolower(substr($const, 7))); | |||||
$state[$method] = $resource->{$method}(); | |||||
} | |||||
} | |||||
if (empty($state['isDeleted']) && method_exists($resource, 'trashed')) { | |||||
$state['isDeleted'] = $resource->trashed(); | |||||
} | |||||
return $state; | |||||
} | } | ||||
/** | /** | ||||
* Prepare a resource object for the UI. | * Prepare a resource object for the UI. | ||||
* | * | ||||
* @param object $object An object | * @param object $object An object | ||||
* @param bool $full Include all object properties | * @param bool $full Include all object properties | ||||
* | * | ||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |