Completed
Push — master ( 455fca...784e36 )
by Innocent
04:49
created

DiscussionObserver::creating()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Faithgen\Discussions\Observers;
4
5
use Faithgen\Discussions\Models\Discussion;
6
use FaithGen\SDK\Models\User;
7
use FaithGen\SDK\Traits\FileTraits;
8
use Illuminate\Support\Str;
9
10
class DiscussionObserver
11
{
12
    use FileTraits;
13
14
    /**
15
     * Handle the discussion "created" event.
16
     *
17
     * @param  \Faithgen\Discussions\Models\Discussion  $discussion
18
     *
19
     * @return void
20
     */
21
    public function created(Discussion $discussion)
0 ignored issues
show
Unused Code introduced by
The parameter $discussion is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        //
24
    }
25
26
    /**
27
     * Handle the discussion "updated" event.
28
     *
29
     * @param  \Faithgen\Discussions\Models\Discussion  $discussion
30
     *
31
     * @return void
32
     */
33
    public function updated(Discussion $discussion)
0 ignored issues
show
Unused Code introduced by
The parameter $discussion is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        //
36
    }
37
38
    /**
39
     * Handle the discussion "deleted" event.
40
     *
41
     * @param  \Faithgen\Discussions\Models\Discussion  $discussion
42
     *
43
     * @return void
44
     */
45
    public function deleted(Discussion $discussion)
46
    {
47
        if ($discussion->images) {
48
            $this->deleteFiles($discussion);
49
        }
50
    }
51
52
    public function creating(Discussion $discussion)
53
    {
54
        if (Str::of($discussion->discussable_type)->contains('User')) {
55
            $discussion->discussable_type = User::class;
56
        }
57
    }
58
}
59