|
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')); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
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:
The
getFirstName()method in theSoncalls the wrong method in the parent class.