GuestService::getUnsetFields()   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 Innoflash\Events\Services;
4
5
use Innoflash\Events\Models\Event;
6
use Innoflash\Events\Models\Guest;
7
use InnoFlash\LaraStart\Services\CRUDServices;
8
9
class GuestService extends CRUDServices
10
{
11
    protected Guest $guest;
12
13
    public function __construct()
14
    {
15
        $this->guest = app(Guest::class);
16
17
        $guestId = request()->route('guest') ?? request('guest_id');
18
19
        if ($guestId) {
20
            $this->guest = $this->guest->resolveRouteBinding($guestId);
21
        }
22
    }
23
24
    /**
25
     * Retrieves an instance of guest.
26
     *
27
     * @return \Innoflash\Events\Models\Guest
28
     */
29
    public function getGuest(): Guest
30
    {
31
        return $this->guest;
32
    }
33
34
    /**
35
     * Makes a list of fields that you do not want to be sent
36
     * to the create or update methods.
37
     * Its mainly the fields that you do not have in the messages table.
38
     *
39
     * @return array
40
     */
41
    public function getUnsetFields(): array
42
    {
43
        return ['guest_id', 'image'];
44
    }
45
46
    /**
47
     * Attaches a parent to the current guest
48
     * You can delete this if you do not intent to create guests from parent relationships.
49
     */
50
    public function getParentRelationship()
51
    {
52
        return [
53
            Event::class,
54
            'guests',
55
        ];
56
    }
57
}
58