@@ -5,32 +5,32 @@ |
||
5 | 5 | |
6 | 6 | class Report extends Model{ |
7 | 7 | |
8 | - use SoftDeletes; |
|
8 | + use SoftDeletes; |
|
9 | 9 | protected $table = 'reports'; |
10 | 10 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
11 | 11 | protected $hidden = ['deleted_at']; |
12 | 12 | protected $guarded = ['id']; |
13 | 13 | protected $fillable = ['report_name', 'view_name']; |
14 | - public $searchable = ['report_name', 'view_name']; |
|
14 | + public $searchable = ['report_name', 'view_name']; |
|
15 | 15 | |
16 | 16 | public function getCreatedAtAttribute($value) |
17 | - { |
|
18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | - } |
|
17 | + { |
|
18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | + } |
|
20 | 20 | |
21 | - public function getUpdatedAtAttribute($value) |
|
22 | - { |
|
23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | - } |
|
21 | + public function getUpdatedAtAttribute($value) |
|
22 | + { |
|
23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | + } |
|
25 | 25 | |
26 | - public function getDeletedAtAttribute($value) |
|
27 | - { |
|
28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | - } |
|
26 | + public function getDeletedAtAttribute($value) |
|
27 | + { |
|
28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | + } |
|
30 | 30 | |
31 | - public static function boot() |
|
32 | - { |
|
33 | - parent::boot(); |
|
34 | - Report::observe(\App::make('App\Modules\Reporting\ModelObservers\ReprotObserver')); |
|
35 | - } |
|
31 | + public static function boot() |
|
32 | + { |
|
33 | + parent::boot(); |
|
34 | + Report::observe(\App::make('App\Modules\Reporting\ModelObservers\ReprotObserver')); |
|
35 | + } |
|
36 | 36 | } |
@@ -5,37 +5,37 @@ |
||
5 | 5 | |
6 | 6 | class Settings extends Model{ |
7 | 7 | |
8 | - use SoftDeletes; |
|
9 | - protected $table = 'settings'; |
|
10 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | - protected $hidden = ['deleted_at']; |
|
12 | - protected $guarded = ['id', 'key']; |
|
13 | - protected $fillable = ['name','value']; |
|
14 | - public $searchable = ['name', 'value', 'key']; |
|
8 | + use SoftDeletes; |
|
9 | + protected $table = 'settings'; |
|
10 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | + protected $hidden = ['deleted_at']; |
|
12 | + protected $guarded = ['id', 'key']; |
|
13 | + protected $fillable = ['name','value']; |
|
14 | + public $searchable = ['name', 'value', 'key']; |
|
15 | 15 | |
16 | - public function getCreatedAtAttribute($value) |
|
17 | - { |
|
18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | - } |
|
16 | + public function getCreatedAtAttribute($value) |
|
17 | + { |
|
18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | + } |
|
20 | 20 | |
21 | - public function getUpdatedAtAttribute($value) |
|
22 | - { |
|
23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | - } |
|
21 | + public function getUpdatedAtAttribute($value) |
|
22 | + { |
|
23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | + } |
|
25 | 25 | |
26 | - public function getDeletedAtAttribute($value) |
|
27 | - { |
|
28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | - } |
|
26 | + public function getDeletedAtAttribute($value) |
|
27 | + { |
|
28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | + } |
|
30 | 30 | |
31 | - public function newCollection(array $models = []) |
|
32 | - { |
|
33 | - return parent::newCollection($models)->keyBy('key'); |
|
34 | - } |
|
31 | + public function newCollection(array $models = []) |
|
32 | + { |
|
33 | + return parent::newCollection($models)->keyBy('key'); |
|
34 | + } |
|
35 | 35 | |
36 | - public static function boot() |
|
37 | - { |
|
38 | - parent::boot(); |
|
39 | - Settings::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
40 | - } |
|
36 | + public static function boot() |
|
37 | + { |
|
38 | + parent::boot(); |
|
39 | + Settings::observe(\App::make('App\Modules\Core\ModelObservers\SettingsObserver')); |
|
40 | + } |
|
41 | 41 | } |
@@ -5,37 +5,37 @@ |
||
5 | 5 | |
6 | 6 | class AclPermission extends Model { |
7 | 7 | |
8 | - use SoftDeletes; |
|
9 | - protected $table = 'permissions'; |
|
10 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | - protected $hidden = ['deleted_at']; |
|
12 | - protected $guarded = ['id']; |
|
13 | - protected $fillable = ['name', 'model']; |
|
14 | - public $searchable = ['name', 'model']; |
|
8 | + use SoftDeletes; |
|
9 | + protected $table = 'permissions'; |
|
10 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | + protected $hidden = ['deleted_at']; |
|
12 | + protected $guarded = ['id']; |
|
13 | + protected $fillable = ['name', 'model']; |
|
14 | + public $searchable = ['name', 'model']; |
|
15 | 15 | |
16 | - public function getCreatedAtAttribute($value) |
|
17 | - { |
|
18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | - } |
|
16 | + public function getCreatedAtAttribute($value) |
|
17 | + { |
|
18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | + } |
|
20 | 20 | |
21 | - public function getUpdatedAtAttribute($value) |
|
22 | - { |
|
23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | - } |
|
21 | + public function getUpdatedAtAttribute($value) |
|
22 | + { |
|
23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | + } |
|
25 | 25 | |
26 | - public function getDeletedAtAttribute($value) |
|
27 | - { |
|
28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | - } |
|
26 | + public function getDeletedAtAttribute($value) |
|
27 | + { |
|
28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | + } |
|
30 | 30 | |
31 | - public function groups() |
|
32 | - { |
|
33 | - return $this->belongsToMany('\App\Modules\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
34 | - } |
|
31 | + public function groups() |
|
32 | + { |
|
33 | + return $this->belongsToMany('\App\Modules\Acl\AclGroup','groups_permissions','permission_id','group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
34 | + } |
|
35 | 35 | |
36 | - public static function boot() |
|
37 | - { |
|
38 | - parent::boot(); |
|
39 | - AclPermission::observe(\App::make('App\Modules\Acl\ModelObservers\AclPermissionObserver')); |
|
40 | - } |
|
36 | + public static function boot() |
|
37 | + { |
|
38 | + parent::boot(); |
|
39 | + AclPermission::observe(\App::make('App\Modules\Acl\ModelObservers\AclPermissionObserver')); |
|
40 | + } |
|
41 | 41 | } |
@@ -7,135 +7,135 @@ |
||
7 | 7 | |
8 | 8 | class AclUser extends User { |
9 | 9 | |
10 | - use SoftDeletes, HasApiTokens; |
|
11 | - protected $table = 'users'; |
|
12 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | - protected $hidden = ['password', 'remember_token','deleted_at']; |
|
14 | - protected $guarded = ['id']; |
|
15 | - protected $fillable = ['profile_picture', 'name', 'email', 'password']; |
|
16 | - public $searchable = ['name', 'email']; |
|
10 | + use SoftDeletes, HasApiTokens; |
|
11 | + protected $table = 'users'; |
|
12 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | + protected $hidden = ['password', 'remember_token','deleted_at']; |
|
14 | + protected $guarded = ['id']; |
|
15 | + protected $fillable = ['profile_picture', 'name', 'email', 'password']; |
|
16 | + public $searchable = ['name', 'email']; |
|
17 | 17 | |
18 | - public function getCreatedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | - } |
|
22 | - |
|
23 | - public function getUpdatedAtAttribute($value) |
|
24 | - { |
|
25 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
26 | - } |
|
27 | - |
|
28 | - public function getDeletedAtAttribute($value) |
|
29 | - { |
|
30 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * Encrypt the password attribute before |
|
35 | - * saving it in the storage. |
|
36 | - * |
|
37 | - * @param string $value |
|
38 | - */ |
|
39 | - public function setPasswordAttribute($value) |
|
40 | - { |
|
41 | - $this->attributes['password'] = bcrypt($value); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Get the entity's notifications. |
|
46 | - */ |
|
47 | - public function notifications() |
|
48 | - { |
|
49 | - return $this->morphMany('\App\Modules\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc'); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Get the entity's read notifications. |
|
54 | - */ |
|
55 | - public function readNotifications() |
|
56 | - { |
|
57 | - return $this->notifications()->whereNotNull('read_at'); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Get the entity's unread notifications. |
|
62 | - */ |
|
63 | - public function unreadNotifications() |
|
64 | - { |
|
65 | - return $this->notifications()->whereNull('read_at'); |
|
66 | - } |
|
67 | - |
|
68 | - public function groups() |
|
69 | - { |
|
70 | - return $this->belongsToMany('\App\Modules\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
71 | - } |
|
72 | - |
|
73 | - public function oauthClients() |
|
74 | - { |
|
75 | - return $this->hasMany('App\Modules\Acl\OauthClient', 'user_id'); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Return fcm device tokens that will be used in sending fcm notifications. |
|
80 | - * |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function routeNotificationForFCM() |
|
84 | - { |
|
85 | - $devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]); |
|
86 | - $tokens = []; |
|
87 | - |
|
88 | - foreach ($devices as $device) |
|
89 | - { |
|
90 | - $accessToken = decrypt($device->access_token); |
|
91 | - |
|
92 | - try |
|
93 | - { |
|
94 | - if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) |
|
95 | - { |
|
96 | - continue; |
|
97 | - } |
|
98 | - |
|
99 | - $tokens[] = $device->device_token; |
|
100 | - } |
|
101 | - catch (\Exception $e) |
|
102 | - { |
|
103 | - $device->forceDelete(); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - return $tokens; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * The channels the user receives notification broadcasts on. |
|
112 | - * |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function receivesBroadcastNotificationsOn() |
|
116 | - { |
|
117 | - return 'users.' . $this->id; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Custom password validation. |
|
122 | - * |
|
123 | - * @param string $password |
|
124 | - * @return boolean |
|
125 | - */ |
|
126 | - public function validateForPassportPasswordGrant($password) |
|
127 | - { |
|
128 | - if ($password == config('skeleton.social_pass')) |
|
129 | - { |
|
130 | - return true; |
|
131 | - } |
|
132 | - |
|
133 | - return \Hash::check($password, $this->password); |
|
134 | - } |
|
18 | + public function getCreatedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | + } |
|
22 | + |
|
23 | + public function getUpdatedAtAttribute($value) |
|
24 | + { |
|
25 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
26 | + } |
|
27 | + |
|
28 | + public function getDeletedAtAttribute($value) |
|
29 | + { |
|
30 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * Encrypt the password attribute before |
|
35 | + * saving it in the storage. |
|
36 | + * |
|
37 | + * @param string $value |
|
38 | + */ |
|
39 | + public function setPasswordAttribute($value) |
|
40 | + { |
|
41 | + $this->attributes['password'] = bcrypt($value); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Get the entity's notifications. |
|
46 | + */ |
|
47 | + public function notifications() |
|
48 | + { |
|
49 | + return $this->morphMany('\App\Modules\Notifications\Notification', 'notifiable')->orderBy('created_at', 'desc'); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Get the entity's read notifications. |
|
54 | + */ |
|
55 | + public function readNotifications() |
|
56 | + { |
|
57 | + return $this->notifications()->whereNotNull('read_at'); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Get the entity's unread notifications. |
|
62 | + */ |
|
63 | + public function unreadNotifications() |
|
64 | + { |
|
65 | + return $this->notifications()->whereNull('read_at'); |
|
66 | + } |
|
67 | + |
|
68 | + public function groups() |
|
69 | + { |
|
70 | + return $this->belongsToMany('\App\Modules\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
71 | + } |
|
72 | + |
|
73 | + public function oauthClients() |
|
74 | + { |
|
75 | + return $this->hasMany('App\Modules\Acl\OauthClient', 'user_id'); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Return fcm device tokens that will be used in sending fcm notifications. |
|
80 | + * |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function routeNotificationForFCM() |
|
84 | + { |
|
85 | + $devices = \Core::pushNotificationsDevices()->findBy(['user_id' => $this->id]); |
|
86 | + $tokens = []; |
|
87 | + |
|
88 | + foreach ($devices as $device) |
|
89 | + { |
|
90 | + $accessToken = decrypt($device->access_token); |
|
91 | + |
|
92 | + try |
|
93 | + { |
|
94 | + if (\Core::users()->accessTokenExpiredOrRevoked($accessToken)) |
|
95 | + { |
|
96 | + continue; |
|
97 | + } |
|
98 | + |
|
99 | + $tokens[] = $device->device_token; |
|
100 | + } |
|
101 | + catch (\Exception $e) |
|
102 | + { |
|
103 | + $device->forceDelete(); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + return $tokens; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * The channels the user receives notification broadcasts on. |
|
112 | + * |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function receivesBroadcastNotificationsOn() |
|
116 | + { |
|
117 | + return 'users.' . $this->id; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Custom password validation. |
|
122 | + * |
|
123 | + * @param string $password |
|
124 | + * @return boolean |
|
125 | + */ |
|
126 | + public function validateForPassportPasswordGrant($password) |
|
127 | + { |
|
128 | + if ($password == config('skeleton.social_pass')) |
|
129 | + { |
|
130 | + return true; |
|
131 | + } |
|
132 | + |
|
133 | + return \Hash::check($password, $this->password); |
|
134 | + } |
|
135 | 135 | |
136 | - public static function boot() |
|
137 | - { |
|
138 | - parent::boot(); |
|
139 | - AclUser::observe(\App::make('App\Modules\Acl\ModelObservers\AclUserObserver')); |
|
140 | - } |
|
136 | + public static function boot() |
|
137 | + { |
|
138 | + parent::boot(); |
|
139 | + AclUser::observe(\App::make('App\Modules\Acl\ModelObservers\AclUserObserver')); |
|
140 | + } |
|
141 | 141 | } |
@@ -6,23 +6,23 @@ |
||
6 | 6 | |
7 | 7 | class OauthClient extends Client |
8 | 8 | { |
9 | - protected $dates = ['created_at', 'updated_at']; |
|
10 | - protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
11 | - public $searchable = ['name']; |
|
9 | + protected $dates = ['created_at', 'updated_at']; |
|
10 | + protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked']; |
|
11 | + public $searchable = ['name']; |
|
12 | 12 | |
13 | - public function getCreatedAtAttribute($value) |
|
14 | - { |
|
15 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
16 | - } |
|
13 | + public function getCreatedAtAttribute($value) |
|
14 | + { |
|
15 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
16 | + } |
|
17 | 17 | |
18 | - public function getUpdatedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | - } |
|
18 | + public function getUpdatedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | + } |
|
22 | 22 | |
23 | - public static function boot() |
|
24 | - { |
|
25 | - parent::boot(); |
|
26 | - OauthClient::observe(\App::make('App\Modules\Acl\ModelObservers\OauthClientObserver')); |
|
27 | - } |
|
23 | + public static function boot() |
|
24 | + { |
|
25 | + parent::boot(); |
|
26 | + OauthClient::observe(\App::make('App\Modules\Acl\ModelObservers\OauthClientObserver')); |
|
27 | + } |
|
28 | 28 | } |
@@ -5,42 +5,42 @@ |
||
5 | 5 | |
6 | 6 | class AclGroup extends Model{ |
7 | 7 | |
8 | - use SoftDeletes; |
|
9 | - protected $table = 'groups'; |
|
10 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | - protected $hidden = ['deleted_at']; |
|
12 | - protected $guarded = ['id']; |
|
13 | - protected $fillable = ['name']; |
|
14 | - public $searchable = ['name']; |
|
15 | - |
|
16 | - public function getCreatedAtAttribute($value) |
|
17 | - { |
|
18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | - } |
|
20 | - |
|
21 | - public function getUpdatedAtAttribute($value) |
|
22 | - { |
|
23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | - } |
|
25 | - |
|
26 | - public function getDeletedAtAttribute($value) |
|
27 | - { |
|
28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | - } |
|
30 | - |
|
31 | - public function users() |
|
32 | - { |
|
33 | - return $this->belongsToMany('\App\Modules\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
34 | - } |
|
35 | - |
|
36 | - public function permissions() |
|
37 | - { |
|
38 | - return $this->belongsToMany('\App\Modules\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
39 | - } |
|
40 | - |
|
41 | - public static function boot() |
|
42 | - { |
|
43 | - parent::boot(); |
|
44 | - AclGroup::observe(\App::make('App\Modules\Acl\ModelObservers\AclGroupObserver')); |
|
45 | - } |
|
8 | + use SoftDeletes; |
|
9 | + protected $table = 'groups'; |
|
10 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | + protected $hidden = ['deleted_at']; |
|
12 | + protected $guarded = ['id']; |
|
13 | + protected $fillable = ['name']; |
|
14 | + public $searchable = ['name']; |
|
15 | + |
|
16 | + public function getCreatedAtAttribute($value) |
|
17 | + { |
|
18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | + } |
|
20 | + |
|
21 | + public function getUpdatedAtAttribute($value) |
|
22 | + { |
|
23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | + } |
|
25 | + |
|
26 | + public function getDeletedAtAttribute($value) |
|
27 | + { |
|
28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | + } |
|
30 | + |
|
31 | + public function users() |
|
32 | + { |
|
33 | + return $this->belongsToMany('\App\Modules\Acl\AclUser','users_groups','group_id','user_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
34 | + } |
|
35 | + |
|
36 | + public function permissions() |
|
37 | + { |
|
38 | + return $this->belongsToMany('\App\Modules\Acl\AclPermission','groups_permissions','group_id','permission_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
39 | + } |
|
40 | + |
|
41 | + public static function boot() |
|
42 | + { |
|
43 | + parent::boot(); |
|
44 | + AclGroup::observe(\App::make('App\Modules\Acl\ModelObservers\AclGroupObserver')); |
|
45 | + } |
|
46 | 46 | } |
@@ -5,48 +5,48 @@ |
||
5 | 5 | |
6 | 6 | class PushNotificationDevice extends Model{ |
7 | 7 | |
8 | - use SoftDeletes; |
|
9 | - protected $table = 'push_notifications_devices'; |
|
10 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | - protected $hidden = ['deleted_at', 'access_token']; |
|
12 | - protected $guarded = ['id']; |
|
13 | - protected $fillable = ['device_token', 'user_id', 'access_token']; |
|
14 | - public $searchable = ['device_token']; |
|
15 | - |
|
16 | - public function getCreatedAtAttribute($value) |
|
17 | - { |
|
18 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | - } |
|
20 | - |
|
21 | - public function getUpdatedAtAttribute($value) |
|
22 | - { |
|
23 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | - } |
|
25 | - |
|
26 | - public function getDeletedAtAttribute($value) |
|
27 | - { |
|
28 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | - } |
|
8 | + use SoftDeletes; |
|
9 | + protected $table = 'push_notifications_devices'; |
|
10 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
11 | + protected $hidden = ['deleted_at', 'access_token']; |
|
12 | + protected $guarded = ['id']; |
|
13 | + protected $fillable = ['device_token', 'user_id', 'access_token']; |
|
14 | + public $searchable = ['device_token']; |
|
15 | + |
|
16 | + public function getCreatedAtAttribute($value) |
|
17 | + { |
|
18 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
19 | + } |
|
20 | + |
|
21 | + public function getUpdatedAtAttribute($value) |
|
22 | + { |
|
23 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
24 | + } |
|
25 | + |
|
26 | + public function getDeletedAtAttribute($value) |
|
27 | + { |
|
28 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
29 | + } |
|
30 | 30 | |
31 | - public function user() |
|
32 | - { |
|
33 | - return $this->belongsTo('App\Modules\Acl\AclUser'); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * Encrypt the access_token attribute before |
|
38 | - * saving it in the storage. |
|
39 | - * |
|
40 | - * @param string $value |
|
41 | - */ |
|
42 | - public function setLoginTokenAttribute($value) |
|
43 | - { |
|
44 | - $this->attributes['access_token'] = encrypt($value); |
|
45 | - } |
|
46 | - |
|
47 | - public static function boot() |
|
48 | - { |
|
49 | - parent::boot(); |
|
50 | - PushNotificationDevice::observe(\App::make('App\Modules\Notifications\ModelObservers\PushNotificationDeviceObserver')); |
|
51 | - } |
|
31 | + public function user() |
|
32 | + { |
|
33 | + return $this->belongsTo('App\Modules\Acl\AclUser'); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * Encrypt the access_token attribute before |
|
38 | + * saving it in the storage. |
|
39 | + * |
|
40 | + * @param string $value |
|
41 | + */ |
|
42 | + public function setLoginTokenAttribute($value) |
|
43 | + { |
|
44 | + $this->attributes['access_token'] = encrypt($value); |
|
45 | + } |
|
46 | + |
|
47 | + public static function boot() |
|
48 | + { |
|
49 | + parent::boot(); |
|
50 | + PushNotificationDevice::observe(\App::make('App\Modules\Notifications\ModelObservers\PushNotificationDeviceObserver')); |
|
51 | + } |
|
52 | 52 | } |