File size: 675 Bytes
907b200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Str;

class AwardResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'category' => $this->category,
            'images' => $this->images,
            'short_description' => Str::limit($this->description, 100),
            'scientists_count' => $this->when(isset($this->scientists_count), $this->scientists_count),
            'scientists' => \App\Http\Resources\ScientistResource::collection($this->whenLoaded('scientists')),
        ];
    }
}