GuestService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

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

4 Methods

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