Completed
Push — master ( cd8f65...e1eb39 )
by Sherif
27:44
created

AclUser::getPermissionsAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php namespace App\Modules\V1\Acl;
2
3
use Illuminate\Database\Eloquent\Model;
4
use App\User;
5
use Illuminate\Database\Eloquent\SoftDeletes;
6
7
class AclUser extends User {
8
9
    use SoftDeletes;
10
    protected $table    = 'users';
11
    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
12
    protected $hidden   = ['password', 'remember_token','deleted_at'];
13
    protected $guarded  = ['id'];
14
    protected $fillable = ['name', 'email', 'password'];
15
    public $searchable  = ['name', 'email'];
16
    
17
    public function getCreatedAtAttribute($value)
18
    {
19
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
20
    }
21
22
    public function getUpdatedAtAttribute($value)
23
    {
24
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
25
    }
26
27
    public function getDeletedAtAttribute($value)
28
    {
29
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
30
    }
31
32
    /**
33
     * Encrypt the password attribute before
34
     * saving it in the storage.
35
     * 
36
     * @param string $value 
37
     */
38
    public function setPasswordAttribute($value)
39
    {
40
        $this->attributes['password'] = bcrypt($value);
41
    }
42
43
    public function logs()
44
    {
45
        return $this->hasMany('App\Modules\V1\Core\Log', 'user_id');
46
    }
47
48
    public function groups()
49
    {
50
        return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps();
51
    }
52
    
53
    public static function boot()
54
    {
55
        parent::boot();
56
        parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver'));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (observe() instead of boot()). Are you sure this is correct? If so, you might want to change this to $this->observe().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
57
    }
58
}
59