1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FaithGen\SDK\Http\Resources; |
4
|
|
|
|
5
|
|
|
use FaithGen\SDK\Helpers\ImageHelper; |
6
|
|
|
use Illuminate\Http\Resources\Json\JsonResource; |
7
|
|
|
use InnoFlash\LaraStart\Helper; |
8
|
|
|
|
9
|
|
|
class Profile extends JsonResource |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Transform the resource into an array. |
13
|
|
|
* |
14
|
|
|
* @param \Illuminate\Http\Request $request |
15
|
|
|
* |
16
|
|
|
* @return array |
17
|
|
|
*/ |
18
|
|
|
public function toArray($request) |
19
|
|
|
{ |
20
|
|
|
return [ |
21
|
|
|
'id' => $this->id, |
|
|
|
|
22
|
|
|
'name' => $this->name, |
|
|
|
|
23
|
|
|
'email' => $this->email, |
|
|
|
|
24
|
|
|
'phone' => $this->phone, |
|
|
|
|
25
|
|
|
'color' => $this->profile->color, |
|
|
|
|
26
|
|
|
'active' => (bool) $this->activation->active, |
|
|
|
|
27
|
|
|
'api_key' => $this->apiKey->api_key, |
|
|
|
|
28
|
|
|
'avatar' => ImageHelper::getImage('profile', $this->image, config('faithgen-sdk.ministries-server')), |
|
|
|
|
29
|
|
|
'date' => Helper::getDates($this->created_at), |
|
|
|
|
30
|
|
|
'users' => [ |
31
|
|
|
'count' => $this->ministryUsers()->count(), |
|
|
|
|
32
|
|
|
], |
33
|
|
|
'location' => is_array($this->profile->location) |
34
|
|
|
? $this->profile->location |
35
|
|
|
: json_decode($this->profile->location), |
36
|
|
|
'links' => [ |
37
|
|
|
'website' => $this->profile->website, |
38
|
|
|
'facebook' => $this->profile->facebook, |
39
|
|
|
'youtube' => $this->profile->youtube, |
40
|
|
|
'twitter' => $this->profile->twitter, |
41
|
|
|
'instagram' => $this->profile->instagram, |
42
|
|
|
], |
43
|
|
|
'contact' => [ |
44
|
|
|
'phones' => $this->phones, |
|
|
|
|
45
|
|
|
'emails' => $this->emails, |
|
|
|
|
46
|
|
|
], |
47
|
|
|
'services' => DailyService::collection($this->services), |
|
|
|
|
48
|
|
|
'statement' => [ |
49
|
|
|
'vision' => $this->profile->vision, |
50
|
|
|
'mission' => $this->profile->mission, |
51
|
|
|
'about_us' => $this->profile->about_us, |
52
|
|
|
], |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|