Passed
Push — main ( 2e9e01...1bac82 )
by PRATIK
15:02
created

EventResource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 10
dl 0
loc 31
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A with() 0 5 1
A toArray() 0 8 1
1
<?php
2
3
namespace Adminetic\Website\Http\Resources\Event;
4
5
use Illuminate\Http\Resources\Json\JsonResource;
6
use Adminetic\Website\Http\Resources\Gallery\GalleryResource;
7
8
class EventResource extends JsonResource
9
{
10
    /**
11
     * Transform the resource into an array.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @return array
15
     */
16
    public function toArray($request)
17
    {
18
        return [
19
            'type' => 'events',
20
            'id' => (string) $this->id,
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on Adminetic\Website\Http\R...ces\Event\EventResource. Since you implemented __get, consider adding a @property annotation.
Loading history...
21
            'attributes' => parent::toArray($request),
22
            'links' => [
23
                'self' => adminShowRoute('event', $this->id)
0 ignored issues
show
Bug introduced by
The function adminShowRoute was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
                'self' => /** @scrutinizer ignore-call */ adminShowRoute('event', $this->id)
Loading history...
24
            ]
25
        ];
26
    }
27
28
    /**
29
     * Get additional data that should be returned with the resource array.
30
     *
31
     * @param  \Illuminate\Http\Request  $request
32
     * @return array
33
     */
34
    public function with($request)
35
    {
36
        return [
37
            'relationships' => [
38
                'gallery' => GalleryResource::collection($this->whenLoaded('gallery')),
39
            ],
40
        ];
41
    }
42
}
43