Completed
Push — master ( 107204...169de4 )
by Innocent
13:28
created

TestimoniesService::getModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Faithgen\Testimonies\Services;
4
5
use Faithgen\Testimonies\Models\Testimony;
6
use InnoFlash\LaraStart\Services\CRUDServices;
7
8
final class TestimoniesService extends CRUDServices
9
{
10
    protected Testimony $testimony;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
11
12
    public function __construct()
13
    {
14
        $this->testimony = app(Testimony::class);
15
16
        $testimonyId = request()->route('testimony') ?? request('testimony_id');
17
18
        if ($testimonyId) {
19
            $this->testimony = $this->testimony->resolveRouteBinding($testimonyId);
20
        }
21
    }
22
23
    /**
24
     * Retrieves an instance of testimony.
25
     *
26
     * @return \Faithgen\Testimonies\Models\Testimony
27
     */
28
    public function getTestimony(): Testimony
29
    {
30
        return $this->testimony;
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 ['testimony_id'];
43
    }
44
45
    /**
46
     * Attaches a parent to the current testimony
47
     * You can delete this if you do not intent to create testimonys from parent relationships.
48
     */
49
    public function getParentRelationship()
50
    {
51
        return auth()->user()->testimonies();
52
    }
53
}
54