Файловый менеджер - Редактировать - /home/clickysoft/public_html/assets.clickysoft.net/app/Http/Resources/Api/UserShowResource.php
Назад
<?php namespace App\Http\Resources\Api; use App\Models\CompanyUser; use Illuminate\Http\Resources\Json\JsonResource; class UserShowResource extends JsonResource { public function toArray($request) { $userCompanies = CompanyUser::with(["company", "branch"])->whereUserId($this->id)->get(); $companies = []; foreach ($userCompanies as $userCompany) { $companies[] = [ "index" => $userCompany->company_id . "-" . $userCompany->branch_id, "company" => ["label" => $userCompany->company->name, "value" => $userCompany->company->id], "branch" => ["label" => $userCompany->branch->name, "value" => $userCompany->branch->id], ]; } $roleIds = []; $roleNames = []; foreach ($this->roles as $role) { $roleIds[] = $role->id; $roleNames[] = $role->title; } return [ "id" => $this->id, "first_name" => $this->first_name, "last_name" => $this->last_name, "name" => $this->full_name, "email" => $this->email, "contact_number" => $this->contact_number, "user_type" => strtolower($this->user_type), "status" => $this->status, "is_org_admin" => $this->is_org_admin === 1, "email_verified" => $this->hasVerifiedEmail(), "avatar" => [ "thumbnail" => $this->avatar?->thumbnail ?? "https://placehold.co/100x100/EEE/31343C?font-Lato&text=" . strtoupper(substr($this->first_name, 0, 2)), "url" => $this->avatar?->url ?? "https://placehold.co/200x200/EEE/31343C?font-Lato&text=" . strtoupper(substr($this->first_name, 0, 2)), ], "organization" => [ "id" => $this->organization->id, "name" => $this->organization->name, "logo" => [ "thumbnail" => $this->organization->logo?->thumbnail ?? "https://placehold.co/100x100/EEE/31343C?font-Lato&text=" . substr($this->organization->name, 0, 2), "url" => $this->organization->logo?->url ?? "https://placehold.co/100x100/EEE/31343C?font-Lato&text=" . substr($this->organization->name, 0, 2), ] ], "companies" => $companies, "roles" => $roleIds, "rolesName" => $roleNames, "permissions" => [], "created_at" => $this->created_at, "updated_at" => $this->updated_at, ]; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка