You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
884 B
34 lines
884 B
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class UserResource extends JsonResource
|
|
{
|
|
public function toArray($request)
|
|
{
|
|
$resource = [
|
|
'_service' => 'user',
|
|
'_resource' => 'user',
|
|
];
|
|
foreach ($this->getAttributes() as $attribute => $value) {
|
|
switch ($attribute) {
|
|
case 'id':
|
|
case 'name':
|
|
case 'mobile':
|
|
case 'email':
|
|
case 'created_at':
|
|
case 'updated_at':
|
|
$resource[$attribute] = $value;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
$resource['includes']['fingerprints'] = $this->whenLoaded('fingerprints', function () {
|
|
return FingerprintResource::collection($this->fingerprints);
|
|
});
|
|
|
|
return $resource;
|
|
}
|
|
}
|