25 lines
616 B
PHP
25 lines
616 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\V2\Students;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class GuardianResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
$value = $this->resource;
|
|
if (is_array($value)) {
|
|
return $value;
|
|
}
|
|
if (is_object($value) && method_exists($value, 'toArray')) {
|
|
return $value->toArray();
|
|
}
|
|
if (is_object($value)) {
|
|
return get_object_vars($value);
|
|
}
|
|
return ['value' => $value];
|
|
}
|
|
}
|