Completed
Push — master ( 58043b...413e7c )
by Sergi Tur
06:39
created

UserObserver::created()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Acacha\Users\Observers;
4
5
use App\User;
6
use Venturecraft\Revisionable\Revision;
7
8
/**
9
 * Class UserObserver.
10
 */
11
class UserObserver
12
{
13
14
    /**
15
     * Listen to the User created event.
16
     *
17
     * @param  User $user
18
     * @return void
19
     */
20
    public function created(User $user)
0 ignored issues
show
Unused Code introduced by
The parameter $user 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...
21
    {
22
23
    }
24
25
    /**
26
     * Listen to the User deleted event.
27
     */
28 View Code Duplication
    public function deleted(User $user)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        \DB::table((new Revision())->getTable())->insert([
31
            [
32
                'revisionable_type' => $user->getMorphClass(),
33
                'revisionable_id' => $user->id,
34
                'key' => 'deleted_at',
35
                'old_value' => $user,
36
                'new_value' => new \DateTime(),
37
                'user_id' => (\Auth::check() ? \Auth::user()->id : null),
38
                'created_at' => new \DateTime(),
39
                'updated_at' => new \DateTime(),
40
            ]
41
        ]);
42
    }
43
}