File size: 848 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
24
25
26
27
28
<?php

namespace App\Http\Resources;

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

class ScientistResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'nationality' => $this->nationality,
            'birth_year' => $this->birth_year,
            'death_year' => $this->death_year,
            'field' => $this->field,
            'images' => $this->images,
            'bio' => $this->bio,
            'short_bio' => Str::limit($this->bio, 150),
            'impact' => $this->impact,
            'awards_count' => $this->when(isset($this->awards_count), $this->awards_count),
            'awards' => \App\Http\Resources\AwardResource::collection($this->whenLoaded('awards')),
        ];
    }
}