/ app / Http / Resources / NormScopeResource.php
NormScopeResource.php
 1  <?php
 2  
 3  namespace App\Http\Resources;
 4  
 5  use Illuminate\Http\Resources\Json\JsonResource;
 6  
 7  class NormScopeResource extends JsonResource
 8  {
 9      /**
10       * Transform the resource collection into an array.
11       *
12       * @param  \Illuminate\Http\Request  $request
13       * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
14       */
15      public function toArray($request)
16      {
17          return [
18              'id' => $this->id,
19              'name' => $this->name,
20              'description' => $this->description,
21              'norm' => $this->norm,
22              'skills' => $this->skills ? $this->skills->load('evaluator', 'creator') : null,
23              'activities' => $this->activities,
24              'created_at' => $this->created_at,
25              'updated_at' => $this->updated_at,
26          ];
27      }
28  }