@@ -4,67 +4,67 @@ |
||
4 | 4 | |
5 | 5 | class ReportRepository extends AbstractRepository |
6 | 6 | { |
7 | - /** |
|
8 | - * Return the model full namespace. |
|
9 | - * |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - protected function getModel() |
|
13 | - { |
|
14 | - return 'App\Modules\V1\Reporting\Report'; |
|
15 | - } |
|
7 | + /** |
|
8 | + * Return the model full namespace. |
|
9 | + * |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + protected function getModel() |
|
13 | + { |
|
14 | + return 'App\Modules\V1\Reporting\Report'; |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * Render the given report db view based on the given |
|
19 | - * condition. |
|
20 | - * |
|
21 | - * @param string $reportName |
|
22 | - * @param array $conditions array of conditions |
|
23 | - * @param integer $perPage |
|
24 | - * @param array $relations |
|
25 | - * @param boolean $skipPermission |
|
26 | - * @return object |
|
27 | - */ |
|
28 | - public function getReport($reportName, $conditions = false, $perPage = 0, $relations = [], $skipPermission = false) |
|
29 | - { |
|
30 | - /** |
|
31 | - * Fetch the report from db. |
|
32 | - */ |
|
33 | - $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model); |
|
34 | - $report = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($reportConditions['conditionString'], $reportConditions['conditionValues'])->first(); |
|
17 | + /** |
|
18 | + * Render the given report db view based on the given |
|
19 | + * condition. |
|
20 | + * |
|
21 | + * @param string $reportName |
|
22 | + * @param array $conditions array of conditions |
|
23 | + * @param integer $perPage |
|
24 | + * @param array $relations |
|
25 | + * @param boolean $skipPermission |
|
26 | + * @return object |
|
27 | + */ |
|
28 | + public function getReport($reportName, $conditions = false, $perPage = 0, $relations = [], $skipPermission = false) |
|
29 | + { |
|
30 | + /** |
|
31 | + * Fetch the report from db. |
|
32 | + */ |
|
33 | + $reportConditions = $this->constructConditions(['report_name' => $reportName], $this->model); |
|
34 | + $report = call_user_func_array("{$this->getModel()}::with", array($relations))->whereRaw($reportConditions['conditionString'], $reportConditions['conditionValues'])->first(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Check report existance and permission. |
|
38 | - */ |
|
39 | - if ( ! $report) |
|
40 | - { |
|
41 | - \ErrorHandler::notFound('report'); |
|
42 | - } |
|
43 | - else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
44 | - { |
|
45 | - \ErrorHandler::noPermissions(); |
|
46 | - } |
|
36 | + /** |
|
37 | + * Check report existance and permission. |
|
38 | + */ |
|
39 | + if ( ! $report) |
|
40 | + { |
|
41 | + \ErrorHandler::notFound('report'); |
|
42 | + } |
|
43 | + else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
44 | + { |
|
45 | + \ErrorHandler::noPermissions(); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Fetch data from the report based on the given conditions. |
|
50 | - */ |
|
51 | - $report = \DB::table($report->view_name); |
|
52 | - unset($conditions['page']); |
|
53 | - if (count($conditions)) |
|
54 | - { |
|
55 | - $conditions = $this->constructConditions($conditions, $this->model); |
|
56 | - $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
57 | - } |
|
58 | - /** |
|
59 | - * Paginate or all data. |
|
60 | - */ |
|
61 | - if ($perPage) |
|
62 | - { |
|
63 | - return $report->paginate($perPage); |
|
64 | - } |
|
65 | - else |
|
66 | - { |
|
67 | - return $report->get(); |
|
68 | - } |
|
69 | - } |
|
48 | + /** |
|
49 | + * Fetch data from the report based on the given conditions. |
|
50 | + */ |
|
51 | + $report = \DB::table($report->view_name); |
|
52 | + unset($conditions['page']); |
|
53 | + if (count($conditions)) |
|
54 | + { |
|
55 | + $conditions = $this->constructConditions($conditions, $this->model); |
|
56 | + $report->whereRaw($conditions['conditionString'], $conditions['conditionValues']); |
|
57 | + } |
|
58 | + /** |
|
59 | + * Paginate or all data. |
|
60 | + */ |
|
61 | + if ($perPage) |
|
62 | + { |
|
63 | + return $report->paginate($perPage); |
|
64 | + } |
|
65 | + else |
|
66 | + { |
|
67 | + return $report->get(); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | { |
41 | 41 | \ErrorHandler::notFound('report'); |
42 | 42 | } |
43 | - else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
43 | + else if ( ! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
44 | 44 | { |
45 | 45 | \ErrorHandler::noPermissions(); |
46 | 46 | } |
@@ -39,8 +39,7 @@ discard block |
||
39 | 39 | if ( ! $report) |
40 | 40 | { |
41 | 41 | \ErrorHandler::notFound('report'); |
42 | - } |
|
43 | - else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
42 | + } else if (! $skipPermission && ! \Core::users()->can($report->view_name, 'reports')) |
|
44 | 43 | { |
45 | 44 | \ErrorHandler::noPermissions(); |
46 | 45 | } |
@@ -61,8 +60,7 @@ discard block |
||
61 | 60 | if ($perPage) |
62 | 61 | { |
63 | 62 | return $report->paginate($perPage); |
64 | - } |
|
65 | - else |
|
63 | + } else |
|
66 | 64 | { |
67 | 65 | return $report->get(); |
68 | 66 | } |
@@ -5,23 +5,23 @@ |
||
5 | 5 | |
6 | 6 | class Notification extends DatabaseNotification{ |
7 | 7 | |
8 | - public function getCreatedAtAttribute($value) |
|
9 | - { |
|
10 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
11 | - } |
|
8 | + public function getCreatedAtAttribute($value) |
|
9 | + { |
|
10 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
11 | + } |
|
12 | 12 | |
13 | - public function getUpdatedAtAttribute($value) |
|
14 | - { |
|
15 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
16 | - } |
|
13 | + public function getUpdatedAtAttribute($value) |
|
14 | + { |
|
15 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
16 | + } |
|
17 | 17 | |
18 | - public function getDeletedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
21 | - } |
|
18 | + public function getDeletedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
21 | + } |
|
22 | 22 | |
23 | - public function getReadAtAttribute($value) |
|
24 | - { |
|
25 | - return ! $value ? false : \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
26 | - } |
|
23 | + public function getReadAtAttribute($value) |
|
24 | + { |
|
25 | + return ! $value ? false : \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
26 | + } |
|
27 | 27 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | use Illuminate\Notifications\DatabaseNotification; |
4 | 4 | use Illuminate\Database\Eloquent\SoftDeletes; |
5 | 5 | |
6 | -class Notification extends DatabaseNotification{ |
|
6 | +class Notification extends DatabaseNotification { |
|
7 | 7 | |
8 | 8 | public function getCreatedAtAttribute($value) |
9 | 9 | { |
@@ -7,60 +7,60 @@ |
||
7 | 7 | |
8 | 8 | class NotificationsController extends BaseApiController |
9 | 9 | { |
10 | - /** |
|
11 | - * The name of the model that is used by the base api controller |
|
12 | - * to preform actions like (add, edit ... etc). |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $model = 'notifications'; |
|
10 | + /** |
|
11 | + * The name of the model that is used by the base api controller |
|
12 | + * to preform actions like (add, edit ... etc). |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $model = 'notifications'; |
|
16 | 16 | |
17 | - /** |
|
18 | - * List of all route actions that the base api controller |
|
19 | - * will skip permissions check for them. |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'list', 'unread']; |
|
17 | + /** |
|
18 | + * List of all route actions that the base api controller |
|
19 | + * will skip permissions check for them. |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'list', 'unread']; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Retrieve all notifications of the logged in user. |
|
26 | - * |
|
27 | - * @param integer $perPage Number of rows per page default all data. |
|
28 | - * @return \Illuminate\Http\Response |
|
29 | - */ |
|
30 | - public function list($perPage = 0) |
|
31 | - { |
|
32 | - return \Response::json($this->repo->list($perPage), 200); |
|
33 | - } |
|
24 | + /** |
|
25 | + * Retrieve all notifications of the logged in user. |
|
26 | + * |
|
27 | + * @param integer $perPage Number of rows per page default all data. |
|
28 | + * @return \Illuminate\Http\Response |
|
29 | + */ |
|
30 | + public function list($perPage = 0) |
|
31 | + { |
|
32 | + return \Response::json($this->repo->list($perPage), 200); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Retrieve unread notifications of the logged in user. |
|
37 | - * |
|
38 | - * @param integer $perPage Number of rows per page default all data. |
|
39 | - * @return \Illuminate\Http\Response |
|
40 | - */ |
|
41 | - public function unread($perPage = 0) |
|
42 | - { |
|
43 | - return \Response::json($this->repo->unread($perPage), 200); |
|
44 | - } |
|
35 | + /** |
|
36 | + * Retrieve unread notifications of the logged in user. |
|
37 | + * |
|
38 | + * @param integer $perPage Number of rows per page default all data. |
|
39 | + * @return \Illuminate\Http\Response |
|
40 | + */ |
|
41 | + public function unread($perPage = 0) |
|
42 | + { |
|
43 | + return \Response::json($this->repo->unread($perPage), 200); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Mark the notification as read. |
|
48 | - * |
|
49 | - * @param integer $id Id of the notification. |
|
50 | - * @return \Illuminate\Http\Response |
|
51 | - */ |
|
52 | - public function markAsRead($id) |
|
53 | - { |
|
54 | - return \Response::json($this->repo->markAsRead($id), 200); |
|
55 | - } |
|
46 | + /** |
|
47 | + * Mark the notification as read. |
|
48 | + * |
|
49 | + * @param integer $id Id of the notification. |
|
50 | + * @return \Illuminate\Http\Response |
|
51 | + */ |
|
52 | + public function markAsRead($id) |
|
53 | + { |
|
54 | + return \Response::json($this->repo->markAsRead($id), 200); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Mark all notifications as read. |
|
59 | - * |
|
60 | - * @return \Illuminate\Http\Response |
|
61 | - */ |
|
62 | - public function markAllAsRead() |
|
63 | - { |
|
64 | - return \Response::json($this->repo->markAllAsRead(), 200); |
|
65 | - } |
|
57 | + /** |
|
58 | + * Mark all notifications as read. |
|
59 | + * |
|
60 | + * @return \Illuminate\Http\Response |
|
61 | + */ |
|
62 | + public function markAllAsRead() |
|
63 | + { |
|
64 | + return \Response::json($this->repo->markAllAsRead(), 200); |
|
65 | + } |
|
66 | 66 | } |
@@ -5,56 +5,56 @@ |
||
5 | 5 | */ |
6 | 6 | class AclUserObserver { |
7 | 7 | |
8 | - public function saving($model) |
|
9 | - { |
|
10 | - // |
|
11 | - } |
|
12 | - |
|
13 | - public function saved($model) |
|
14 | - { |
|
15 | - // |
|
16 | - } |
|
17 | - |
|
18 | - public function creating($model) |
|
19 | - { |
|
20 | - // |
|
21 | - } |
|
22 | - |
|
23 | - public function created($model) |
|
24 | - { |
|
25 | - // |
|
26 | - } |
|
27 | - |
|
28 | - public function updating($model) |
|
29 | - { |
|
30 | - // |
|
31 | - } |
|
32 | - |
|
33 | - public function updated($model) |
|
34 | - { |
|
35 | - // |
|
36 | - } |
|
37 | - |
|
38 | - public function deleting($model) |
|
39 | - { |
|
40 | - if ($model->getOriginal('id') == \Auth::id()) |
|
41 | - { |
|
42 | - \ErrorHandler::noPermissions(); |
|
43 | - } |
|
44 | - } |
|
45 | - |
|
46 | - public function deleted($model) |
|
47 | - { |
|
48 | - // |
|
49 | - } |
|
50 | - |
|
51 | - public function restoring($model) |
|
52 | - { |
|
53 | - // |
|
54 | - } |
|
55 | - |
|
56 | - public function restored($model) |
|
57 | - { |
|
58 | - // |
|
59 | - } |
|
8 | + public function saving($model) |
|
9 | + { |
|
10 | + // |
|
11 | + } |
|
12 | + |
|
13 | + public function saved($model) |
|
14 | + { |
|
15 | + // |
|
16 | + } |
|
17 | + |
|
18 | + public function creating($model) |
|
19 | + { |
|
20 | + // |
|
21 | + } |
|
22 | + |
|
23 | + public function created($model) |
|
24 | + { |
|
25 | + // |
|
26 | + } |
|
27 | + |
|
28 | + public function updating($model) |
|
29 | + { |
|
30 | + // |
|
31 | + } |
|
32 | + |
|
33 | + public function updated($model) |
|
34 | + { |
|
35 | + // |
|
36 | + } |
|
37 | + |
|
38 | + public function deleting($model) |
|
39 | + { |
|
40 | + if ($model->getOriginal('id') == \Auth::id()) |
|
41 | + { |
|
42 | + \ErrorHandler::noPermissions(); |
|
43 | + } |
|
44 | + } |
|
45 | + |
|
46 | + public function deleted($model) |
|
47 | + { |
|
48 | + // |
|
49 | + } |
|
50 | + |
|
51 | + public function restoring($model) |
|
52 | + { |
|
53 | + // |
|
54 | + } |
|
55 | + |
|
56 | + public function restored($model) |
|
57 | + { |
|
58 | + // |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -7,119 +7,119 @@ |
||
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', 'two_factor_code']; |
|
14 | - protected $guarded = ['id']; |
|
15 | - protected $fillable = ['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', 'two_factor_code']; |
|
14 | + protected $guarded = ['id']; |
|
15 | + protected $fillable = ['name', 'email', 'password']; |
|
16 | + public $searchable = ['name', 'email']; |
|
17 | 17 | |
18 | - public function getCreatedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
21 | - } |
|
22 | - |
|
23 | - public function getUpdatedAtAttribute($value) |
|
24 | - { |
|
25 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
26 | - } |
|
27 | - |
|
28 | - public function getDeletedAtAttribute($value) |
|
29 | - { |
|
30 | - return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->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\V1\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\V1\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\V1\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 | - } |
|
18 | + public function getCreatedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
21 | + } |
|
22 | + |
|
23 | + public function getUpdatedAtAttribute($value) |
|
24 | + { |
|
25 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString(); |
|
26 | + } |
|
27 | + |
|
28 | + public function getDeletedAtAttribute($value) |
|
29 | + { |
|
30 | + return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->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\V1\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\V1\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\V1\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 | 119 | |
120 | - public static function boot() |
|
121 | - { |
|
122 | - parent::boot(); |
|
123 | - parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver')); |
|
124 | - } |
|
120 | + public static function boot() |
|
121 | + { |
|
122 | + parent::boot(); |
|
123 | + parent::observe(\App::make('App\Modules\V1\Acl\ModelObservers\AclUserObserver')); |
|
124 | + } |
|
125 | 125 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use SoftDeletes, HasApiTokens; |
11 | 11 | protected $table = 'users'; |
12 | 12 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
13 | - protected $hidden = ['password', 'remember_token','deleted_at', 'two_factor_code']; |
|
13 | + protected $hidden = ['password', 'remember_token', 'deleted_at', 'two_factor_code']; |
|
14 | 14 | protected $guarded = ['id']; |
15 | 15 | protected $fillable = ['name', 'email', 'password']; |
16 | 16 | public $searchable = ['name', 'email']; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public function groups() |
69 | 69 | { |
70 | - return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup','users_groups','user_id','group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
70 | + return $this->belongsToMany('\App\Modules\V1\Acl\AclGroup', 'users_groups', 'user_id', 'group_id')->whereNull('users_groups.deleted_at')->withTimestamps(); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function oauthClients() |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function receivesBroadcastNotificationsOn() |
116 | 116 | { |
117 | - return 'users.' . $this->id; |
|
117 | + return 'users.'.$this->id; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | public static function boot() |