Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
membrubackend
/
app
/
Http
/
Resources
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
EditKeyResultResource.php
| Size :
2.70
KB
Copy
<?php namespace App\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; use Carbon\Carbon; use App\Models\User; use Auth; class EditKeyResultResource extends JsonResource { /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { $authUser = Auth::user(); $user = $this->user ? $this->user : User::withTrashed()->find($this->user_id); $lastKeyResultLog = $this->lastKeyResultLog(); $diffDays = $lastKeyResultLog ? Carbon::today()->diffInDays($lastKeyResultLog->created_at->startOfDay()) : 0; return [ 'id' => $this->id, 'name' => $this->name, 'objective_id' => $this->objective_id, 'user_id' => $this->user_id, 'user' => $user ? [ 'name' => $user->getFullName(), 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'avatar' => $user->avatar, 'tags' => $user->tags->map(function ($tag) { return [ 'id' => $tag->id, 'name' => $tag->name, 'color_name' => $tag->color ? $tag->color->name : null, 'color_code' => $tag->color ? $tag->color->code : null, ]; }), ] : null, 'description' => $this->description, 'uuid' => $this->uuid, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'percent' => $this->percent, 'status' => $this->status, 'measurement' => $this->measurement, 'unity' => $this->unity, 'target' => $this->target, 'start_value' => $this->start_value, 'progress_type' => $this->progress_type, 'created_at' => $this->created_at, 'tasks_count' => $this->tasks->count(), 'last_update_value' => $lastKeyResultLog ? $lastKeyResultLog->value : $this->start_value, 'needs_an_update' => $this->checkIfNeedsUpdate(), 'diff_days_last_update' => $diffDays, 'rights' => [ 'can_create' => $authUser ? $authUser->can('ownCrudActionOrAdmin', [User::class, $this->resource]) : false, ], ]; } }
Back