Logs::getCreatedByAttribute()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.2
cc 4
eloc 6
nc 4
nop 1
1
<?php namespace jlourenco\base\Models;
2
3
use Illuminate\Database\Eloquent\Model;
4
use jlourenco\base\Repositories\LogRepositoryInterface;
5
use jlourenco\support\Traits\Creation;
6
use Sentinel;
7
8
class Logs extends Model
9
{
10
11
    /**
12
     * To allow user actions identity (Created_by, Updated_by, Deleted_by)
13
     */
14
    use Creation;
15
16
    /**
17
     * {@inheritDoc}
18
     */
19
    protected $table = 'Logs';
20
21
    /**
22
     * {@inheritDoc}
23
     */
24
    protected $fillable = [
25
        'log',
26
        'target',
27
        'ip',
28
    ];
29
30
    /**
31
     * Get the user's first name.
32
     *
33
     * @param  string  $value
34
     * @return string
35
     */
36 View Code Duplication
    public function getCreatedByAttribute($value)
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...
37
    {
38
        if ($value > 0)
39
            if ($user = Sentinel::findUserById($value))
40
                if ($user != null)
41
                    return $user->first_name . ' ' . $user->last_name . ' (ID: ' . $user->id . ')';
42
43
        return $value;
44
    }
45
46
    /**
47
     * Get the user's first name.
48
     *
49
     * @param  string  $value
50
     * @return string
51
     */
52 View Code Duplication
    public function getTargetAttribute($value)
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...
53
    {
54
        if ($value > 0)
55
            if ($user = Sentinel::findUserById($value))
56
                if ($user != null)
57
                    return $user->first_name . ' ' . $user->last_name . ' (ID: ' . $user->id . ')';
58
59
        return $value;
60
    }
61
62
}