35 lines
1015 B
PHP
35 lines
1015 B
PHP
<?php
|
|
|
|
namespace Modules\User\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class UserIdentityRightsResource extends JsonResource
|
|
{
|
|
|
|
public function toArray($request): array
|
|
{
|
|
$rights = $this->rights;
|
|
$data = [];
|
|
if ($rights){
|
|
for ($i = 1; $i <= count($rights); $i++) {
|
|
$data[$i] = [
|
|
'name' => $rights['new_'.$i]['name'] ?? '',
|
|
'cover' => ! empty($rights['new_'.$i]['cover']) ? Storage::url($rights['new_'.$i]['cover']) : '',
|
|
'order' => $rights['new_'.$i]['order'] ?? '',
|
|
'remark' => $rights['new_'.$i]['remark'] ?? '',
|
|
];
|
|
}
|
|
}
|
|
|
|
return [
|
|
'identity_id' => $this->id,
|
|
'name' => $this->name,
|
|
'cover' => $this->cover_url,
|
|
'order' => $this->order,
|
|
'rights' => $data,
|
|
];
|
|
}
|
|
|
|
} |