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

AlbumService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 43
rs 10
c 3
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUnsetFields() 0 3 1
A getParentRelationship() 0 3 1
A getAlbum() 0 3 1
A __construct() 0 8 2
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