Файловый менеджер - Редактировать - /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Resources/Admin/UserResourceWithRoles.php
Назад
<?php namespace App\Http\Resources\Admin; use App\Models\Role; use App\Models\User; use Illuminate\Http\Resources\Json\JsonResource; class UserResourceWithRoles extends JsonResource { public function toArray($request) { // return parent::toArray($request); $user_roles = $roles = $status = $user_types = []; //User existing roles foreach ($this->roles ?? [] as $role){ $user_roles[$role->id] = $role->title; } foreach (Role::all() as $role){ $roles[$role->id] = [ 'id' => $role->id, 'title' => $role->title, 'is_selected' => array_key_exists($role->id, $user_roles), ]; } foreach (User::USER_TYPE_RADIO as $key => $type){ $user_types[] = [ 'id' => $key, 'name' => $type, 'is_selected' => $key == $this->user_type, ]; } foreach (User::STATUS_RADIO as $key => $st){ $status[] = [ 'id' => $key, 'name' => $st, 'is_selected' => $key == $this->status, ]; } return [ 'id' => $this->id, 'name' => $this->name, 'email' => $this->email, 'phone_number' => $this->phone_number, 'company' => $this->company, 'fax_number' => $this->fax_number, 'email_verified' => $this->email_verified_at ? 'Yes' : 'No', 'reminder_duration' => $this->reminder_duration, 'profile_image' => $this->profile_image?->url, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'roles' => $roles, 'user_types' => $user_types, 'birth_date' => $this->birth_date ? $this->birth_date->format('Y-m-d') : $this->birth_date, 'secondary_email' => $this->secondary_email, 'secondary_phone' => $this->secondary_phone, 'status' => $status, ]; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка