Passed
Push — master ( dc648e...bd5a58 )
by Innocent
15:18
created

AlbumService::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\Gallery\Services;
4
5
use FaithGen\Gallery\Models\Album;
6
use InnoFlash\LaraStart\Services\CRUDServices;
7
8
class AlbumService extends CRUDServices
9
{
10
    /**
11
     * @var Album
12
     */
13
    protected Album $album;
14
15
    public function __construct()
16
    {
17
        $this->album = app(Album::class);
18
19
        $albumId = request()->route('album') ?? request('album_id');
20
21
        if ($albumId) {
22
            $this->album = $this->album->resolveRouteBinding($albumId);
23
        }
24
    }
25
26
    /**
27
     * Retrieves an instance of album.
28
     *
29
     * @return \FaithGen\Gallery\Models\Album
30
     */
31
    public function getAlbum(): Album
32
    {
33
        return $this->album;
34
    }
35
36
    /**
37
     * Makes a list of fields that you do not want to be sent
38
     * to the create or update methods.
39
     * Its mainly the fields that you do not have in the messages table.
40
     *
41
     * @return array
42
     */
43
    public function getUnsetFields(): array
44
    {
45
        return ['album_id'];
46
    }
47
48
    public function getParentRelationship()
49
    {
50
        return auth()->user()->albums();
51
    }
52
}
53