Completed
Push — master ( 392340...6e5734 )
by Sherif
07:20
created

AclUserObserver::updating()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php namespace App\Modules\V1\Acl\ModelObservers;
2
3
/**
4
 * Handling of model events,
5
 */
6
class AclUserObserver {
7
8
    public function saving($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
9
    {
10
        //
11
    }
12
13
    public function saved($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
14
    {
15
        //
16
    }
17
18
    public function creating($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
19
    {
20
        //
21
    }
22
23
    public function created($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
24
    {
25
        //
26
    }
27
28
    public function updating($model)
29
    {
30
        if ($model->password) 
31
        {
32
            $model->last_change_password = \Carbon\Carbon::now()->toDateTimeString();
33
        }
34
    }
35
36
    public function updated($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
37
    {
38
        //
39
    }
40
41
    /**
42
     * Soft delete user logs.
43
     * 
44
     * @param  object $model the delted model.
45
     * @return void
46
     */
47
    public function deleting($model)
48
    {
49
        if ($model->getOriginal('id') == \JWTAuth::parseToken()->authenticate()->id) 
50
        {
51
            \ErrorHandler::noPermissions();
52
        }
53
        $model->logs()->delete();
54
    }
55
56
    public function deleted($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
57
    {
58
        //
59
    }
60
61
    public function restoring($model)
62
    {
63
        $model->logs()->restore();
64
    }
65
66
    public function restored($model)
0 ignored issues
show
Unused Code introduced by
The parameter $model 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...
67
    {
68
        //
69
    }
70
}