Passed
Push — master ( 0f1f7e...1fed69 )
by Innocent
09:38
created

ImageService::getModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace FaithGen\SDK\Services;
4
5
use FaithGen\SDK\Models\Image;
6
use InnoFlash\LaraStart\Services\CRUDServices;
7
8
class ImageService extends CRUDServices
9
{
10
    protected Image $image;
11
12
    public function __construct()
13
    {
14
        $this->image = app(Image::class);
15
16
        $imageId = request()->route('image') ?? request('image_id');
17
18
        if ($imageId) {
19
            $this->image = $this->image->resolveRouteBinding($imageId);
20
        }
21
    }
22
23
    /**
24
     * Retrieves an instance of image.
25
     *
26
     * @return \FaithGen\SDK\Models\Image
27
     */
28
    public function getImage(): Image
29
    {
30
        return $this->image;
31
    }
32
33
    /**
34
     * Makes a list of fields that you do not want to be sent
35
     * to the create or update methods.
36
     * Its mainly the fields that you do not have in the messages table.
37
     *
38
     * @return array
39
     */
40
    public function getUnsetFields(): array
41
    {
42
        return ['image_id'];
43
    }
44
}
45