SermonService::getParentRelationship()   A
last analyzed

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\Sermons;
4
5
use FaithGen\SDK\Traits\FileTraits;
6
use FaithGen\Sermons\Models\Sermon;
7
use InnoFlash\LaraStart\Services\CRUDServices;
8
9
class SermonService extends CRUDServices
10
{
11
    use FileTraits;
12
    /**
13
     * @var Sermon
14
     */
15
    protected Sermon $sermon;
16
17
    public function __construct()
18
    {
19
        $this->sermon = app(Sermon::class);
20
21
        $sermonId = request()->route('sermon') ?? request('sermon_id');
22
23
        if ($sermonId) {
24
            $this->sermon = $this->sermon->resolveRouteBinding($sermonId);
25
        }
26
    }
27
28
    /**
29
     * Retrieves an instance of sermon.
30
     *
31
     * @return \FaithGen\Sermons\Models\Sermon
32
     */
33
    public function getSermon(): Sermon
34
    {
35
        return $this->sermon;
36
    }
37
38
    /**
39
     * Makes a list of fields that you do not want to be sent
40
     * to the create or update methods.
41
     * Its mainly the fields that you do not have in the messages table.
42
     *
43
     * @return array
44
     */
45
    public function getUnsetFields(): array
46
    {
47
        return ['sermon_id', 'image'];
48
    }
49
50
    /**
51
     * This gets the relationship of the given model to the parent.
52
     * @return mixed
53
     */
54
    public function getParentRelationship()
55
    {
56
        return auth()->user()->sermons();
57
    }
58
}
59