@@ -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,53 +5,53 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class NotificationObserver { |
| 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 | - // |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function deleted($model) |
|
| 44 | - { |
|
| 45 | - // |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function restoring($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function restored($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 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 | + // |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function deleted($model) |
|
| 44 | + { |
|
| 45 | + // |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function restoring($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function restored($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -5,53 +5,53 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | class PushNotificationDeviceObserver { |
| 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 | - // |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function deleted($model) |
|
| 44 | - { |
|
| 45 | - // |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - public function restoring($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function restored($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 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 | + // |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function deleted($model) |
|
| 44 | + { |
|
| 45 | + // |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + public function restoring($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function restored($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -7,56 +7,56 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PushNotificationDeviceRepository extends AbstractRepository |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Return the model full namespace. |
|
| 12 | - * |
|
| 13 | - * @return string |
|
| 14 | - */ |
|
| 15 | - protected function getModel() |
|
| 16 | - { |
|
| 17 | - return 'App\Modules\Notifications\PushNotificationDevice'; |
|
| 18 | - } |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Register the given device to the logged in user. |
|
| 22 | - * |
|
| 23 | - * @param string $data |
|
| 24 | - * @return void |
|
| 25 | - */ |
|
| 26 | - public function registerDevice($data) |
|
| 27 | - { |
|
| 28 | - $data['access_token'] = \Auth::user()->token(); |
|
| 29 | - $data['user_id'] = \Auth::id(); |
|
| 30 | - if ($device = $this->model->where('device_token', $data['device_token'])->where('user_id', $data['user_id'])->first()) |
|
| 31 | - { |
|
| 32 | - $data['id'] = $device->id; |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - return $this->save($data); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Generate the given message data. |
|
| 40 | - * |
|
| 41 | - * @param string $title |
|
| 42 | - * @param string $message |
|
| 43 | - * @param string $data |
|
| 44 | - * @return void |
|
| 45 | - */ |
|
| 46 | - public function generateMessageData($title, $message, $data = []) |
|
| 47 | - { |
|
| 48 | - $optionBuilder = new OptionsBuilder(); |
|
| 49 | - $notificationBuilder = new PayloadNotificationBuilder($title); |
|
| 50 | - $dataBuilder = new PayloadDataBuilder(); |
|
| 51 | - |
|
| 52 | - $optionBuilder->setTimeToLive(60*20); |
|
| 53 | - $notificationBuilder->setBody($message); |
|
| 54 | - $dataBuilder->addData($data); |
|
| 55 | - |
|
| 56 | - $options = $optionBuilder->build(); |
|
| 57 | - $notification = $notificationBuilder->build(); |
|
| 58 | - $data = $dataBuilder->build(); |
|
| 59 | - |
|
| 60 | - return compact('options', 'notification', 'data'); |
|
| 61 | - } |
|
| 10 | + /** |
|
| 11 | + * Return the model full namespace. |
|
| 12 | + * |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 15 | + protected function getModel() |
|
| 16 | + { |
|
| 17 | + return 'App\Modules\Notifications\PushNotificationDevice'; |
|
| 18 | + } |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Register the given device to the logged in user. |
|
| 22 | + * |
|
| 23 | + * @param string $data |
|
| 24 | + * @return void |
|
| 25 | + */ |
|
| 26 | + public function registerDevice($data) |
|
| 27 | + { |
|
| 28 | + $data['access_token'] = \Auth::user()->token(); |
|
| 29 | + $data['user_id'] = \Auth::id(); |
|
| 30 | + if ($device = $this->model->where('device_token', $data['device_token'])->where('user_id', $data['user_id'])->first()) |
|
| 31 | + { |
|
| 32 | + $data['id'] = $device->id; |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + return $this->save($data); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Generate the given message data. |
|
| 40 | + * |
|
| 41 | + * @param string $title |
|
| 42 | + * @param string $message |
|
| 43 | + * @param string $data |
|
| 44 | + * @return void |
|
| 45 | + */ |
|
| 46 | + public function generateMessageData($title, $message, $data = []) |
|
| 47 | + { |
|
| 48 | + $optionBuilder = new OptionsBuilder(); |
|
| 49 | + $notificationBuilder = new PayloadNotificationBuilder($title); |
|
| 50 | + $dataBuilder = new PayloadDataBuilder(); |
|
| 51 | + |
|
| 52 | + $optionBuilder->setTimeToLive(60*20); |
|
| 53 | + $notificationBuilder->setBody($message); |
|
| 54 | + $dataBuilder->addData($data); |
|
| 55 | + |
|
| 56 | + $options = $optionBuilder->build(); |
|
| 57 | + $notification = $notificationBuilder->build(); |
|
| 58 | + $data = $dataBuilder->build(); |
|
| 59 | + |
|
| 60 | + return compact('options', 'notification', 'data'); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -4,73 +4,73 @@ |
||
| 4 | 4 | |
| 5 | 5 | class NotificationRepository 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\Notifications\Notification'; |
|
| 15 | - } |
|
| 7 | + /** |
|
| 8 | + * Return the model full namespace. |
|
| 9 | + * |
|
| 10 | + * @return string |
|
| 11 | + */ |
|
| 12 | + protected function getModel() |
|
| 13 | + { |
|
| 14 | + return 'App\Modules\Notifications\Notification'; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Retrieve all notifications of the logged in user. |
|
| 19 | - * |
|
| 20 | - * @param integer $perPage |
|
| 21 | - * @return Collection |
|
| 22 | - */ |
|
| 23 | - public function list($perPage) |
|
| 24 | - { |
|
| 25 | - return \Auth::user()->notifications()->paginate($perPage); |
|
| 26 | - } |
|
| 17 | + /** |
|
| 18 | + * Retrieve all notifications of the logged in user. |
|
| 19 | + * |
|
| 20 | + * @param integer $perPage |
|
| 21 | + * @return Collection |
|
| 22 | + */ |
|
| 23 | + public function list($perPage) |
|
| 24 | + { |
|
| 25 | + return \Auth::user()->notifications()->paginate($perPage); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Retrieve unread notifications of the logged in user. |
|
| 30 | - * |
|
| 31 | - * @param integer $perPage |
|
| 32 | - * @return Collection |
|
| 33 | - */ |
|
| 34 | - public function unread($perPage) |
|
| 35 | - { |
|
| 36 | - return \Auth::user()->unreadNotifications()->paginate($perPage); |
|
| 37 | - } |
|
| 28 | + /** |
|
| 29 | + * Retrieve unread notifications of the logged in user. |
|
| 30 | + * |
|
| 31 | + * @param integer $perPage |
|
| 32 | + * @return Collection |
|
| 33 | + */ |
|
| 34 | + public function unread($perPage) |
|
| 35 | + { |
|
| 36 | + return \Auth::user()->unreadNotifications()->paginate($perPage); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Mark the notification as read. |
|
| 41 | - * |
|
| 42 | - * @param integer $id |
|
| 43 | - * @return object |
|
| 44 | - */ |
|
| 45 | - public function markAsRead($id) |
|
| 46 | - { |
|
| 47 | - if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)) |
|
| 48 | - { |
|
| 49 | - $notification->first()->markAsRead(); |
|
| 50 | - } |
|
| 51 | - } |
|
| 39 | + /** |
|
| 40 | + * Mark the notification as read. |
|
| 41 | + * |
|
| 42 | + * @param integer $id |
|
| 43 | + * @return object |
|
| 44 | + */ |
|
| 45 | + public function markAsRead($id) |
|
| 46 | + { |
|
| 47 | + if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)) |
|
| 48 | + { |
|
| 49 | + $notification->first()->markAsRead(); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Mark all notifications as read. |
|
| 55 | - * |
|
| 56 | - * @return void |
|
| 57 | - */ |
|
| 58 | - public function markAllAsRead() |
|
| 59 | - { |
|
| 60 | - \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
| 61 | - } |
|
| 53 | + /** |
|
| 54 | + * Mark all notifications as read. |
|
| 55 | + * |
|
| 56 | + * @return void |
|
| 57 | + */ |
|
| 58 | + public function markAllAsRead() |
|
| 59 | + { |
|
| 60 | + \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Notify th given user with the given notification. |
|
| 65 | - * |
|
| 66 | - * @param collection $users |
|
| 67 | - * @param string $notification |
|
| 68 | - * @param object $notificationData |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - public function notify($users, $notification, $notificationData = false) |
|
| 72 | - { |
|
| 73 | - $notification = 'App\Modules\Notifications\Notifications\\' . $notification; |
|
| 74 | - \Notification::send($users, new $notification($notificationData)); |
|
| 75 | - } |
|
| 63 | + /** |
|
| 64 | + * Notify th given user with the given notification. |
|
| 65 | + * |
|
| 66 | + * @param collection $users |
|
| 67 | + * @param string $notification |
|
| 68 | + * @param object $notificationData |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + public function notify($users, $notification, $notificationData = false) |
|
| 72 | + { |
|
| 73 | + $notification = 'App\Modules\Notifications\Notifications\\' . $notification; |
|
| 74 | + \Notification::send($users, new $notification($notificationData)); |
|
| 75 | + } |
|
| 76 | 76 | } |
@@ -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 | - parent::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 | + parent::observe(\App::make('App\Modules\Notifications\ModelObservers\PushNotificationDeviceObserver')); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -4,65 +4,65 @@ |
||
| 4 | 4 | |
| 5 | 5 | class MakeNotificationsCommand extends GeneratorCommand |
| 6 | 6 | { |
| 7 | - /** |
|
| 8 | - * The name and signature of the console command. |
|
| 9 | - * |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - protected $signature = 'make:module:notification |
|
| 7 | + /** |
|
| 8 | + * The name and signature of the console command. |
|
| 9 | + * |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + protected $signature = 'make:module:notification |
|
| 13 | 13 | {name : The name of the notification class.}'; |
| 14 | - /** |
|
| 15 | - * The console command description. |
|
| 16 | - * |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - protected $description = 'Create a new module notification class'; |
|
| 20 | - /** |
|
| 21 | - * String to store the command type. |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $type = 'Module notification'; |
|
| 26 | - /** |
|
| 27 | - * Get the stub file for the generator. |
|
| 28 | - * |
|
| 29 | - * @return string |
|
| 30 | - */ |
|
| 31 | - protected function getStub() |
|
| 32 | - { |
|
| 33 | - return __DIR__.'/stubs/notification.stub'; |
|
| 34 | - } |
|
| 35 | - /** |
|
| 36 | - * Get the destination class path. |
|
| 37 | - * |
|
| 38 | - * @param string $name |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - protected function getPath($name) |
|
| 43 | - { |
|
| 44 | - return module_path('notifications', 'Notifications/'.$name.'.php'); |
|
| 45 | - } |
|
| 46 | - /** |
|
| 47 | - * Parse the name and format according to the root namespace. |
|
| 48 | - * |
|
| 49 | - * @param string $name |
|
| 50 | - * |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - protected function qualifyClass($name) |
|
| 54 | - { |
|
| 55 | - return $name; |
|
| 56 | - } |
|
| 57 | - /** |
|
| 58 | - * Replace namespace in notification stub. |
|
| 59 | - * |
|
| 60 | - * @param string $name |
|
| 61 | - * |
|
| 62 | - * @return string |
|
| 63 | - */ |
|
| 64 | - protected function getNamespace($name) |
|
| 65 | - { |
|
| 66 | - return module_class('notifications', 'Notifications'); |
|
| 67 | - } |
|
| 14 | + /** |
|
| 15 | + * The console command description. |
|
| 16 | + * |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + protected $description = 'Create a new module notification class'; |
|
| 20 | + /** |
|
| 21 | + * String to store the command type. |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $type = 'Module notification'; |
|
| 26 | + /** |
|
| 27 | + * Get the stub file for the generator. |
|
| 28 | + * |
|
| 29 | + * @return string |
|
| 30 | + */ |
|
| 31 | + protected function getStub() |
|
| 32 | + { |
|
| 33 | + return __DIR__.'/stubs/notification.stub'; |
|
| 34 | + } |
|
| 35 | + /** |
|
| 36 | + * Get the destination class path. |
|
| 37 | + * |
|
| 38 | + * @param string $name |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + protected function getPath($name) |
|
| 43 | + { |
|
| 44 | + return module_path('notifications', 'Notifications/'.$name.'.php'); |
|
| 45 | + } |
|
| 46 | + /** |
|
| 47 | + * Parse the name and format according to the root namespace. |
|
| 48 | + * |
|
| 49 | + * @param string $name |
|
| 50 | + * |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + protected function qualifyClass($name) |
|
| 54 | + { |
|
| 55 | + return $name; |
|
| 56 | + } |
|
| 57 | + /** |
|
| 58 | + * Replace namespace in notification stub. |
|
| 59 | + * |
|
| 60 | + * @param string $name |
|
| 61 | + * |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 64 | + protected function getNamespace($name) |
|
| 65 | + { |
|
| 66 | + return module_class('notifications', 'Notifications'); |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | \ No newline at end of file |
@@ -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 | - parent::observe(\App::make('App\Modules\Acl\ModelObservers\OauthClientObserver')); |
|
| 27 | - } |
|
| 23 | + public static function boot() |
|
| 24 | + { |
|
| 25 | + parent::boot(); |
|
| 26 | + parent::observe(\App::make('App\Modules\Acl\ModelObservers\OauthClientObserver')); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -8,72 +8,72 @@ |
||
| 8 | 8 | class RouteServiceProvider extends ServiceProvider |
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | - * This namespace is applied to your controller routes. |
|
| 12 | - * |
|
| 13 | - * In addition, it is set as the URL generator's root namespace. |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $namespace = 'App\Modules\Acl\Http\Controllers'; |
|
| 11 | + * This namespace is applied to your controller routes. |
|
| 12 | + * |
|
| 13 | + * In addition, it is set as the URL generator's root namespace. |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $namespace = 'App\Modules\Acl\Http\Controllers'; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Define your route model bindings, pattern filters, etc. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function boot() |
|
| 25 | - { |
|
| 26 | - // |
|
| 19 | + /** |
|
| 20 | + * Define your route model bindings, pattern filters, etc. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function boot() |
|
| 25 | + { |
|
| 26 | + // |
|
| 27 | 27 | |
| 28 | - parent::boot(); |
|
| 29 | - } |
|
| 28 | + parent::boot(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Define the routes for the module. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 36 | - public function map() |
|
| 37 | - { |
|
| 38 | - $this->mapWebRoutes(); |
|
| 31 | + /** |
|
| 32 | + * Define the routes for the module. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | + public function map() |
|
| 37 | + { |
|
| 38 | + $this->mapWebRoutes(); |
|
| 39 | 39 | |
| 40 | - $this->mapApiRoutes(); |
|
| 40 | + $this->mapApiRoutes(); |
|
| 41 | 41 | |
| 42 | - // |
|
| 43 | - } |
|
| 42 | + // |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Define the "web" routes for the module. |
|
| 47 | - * |
|
| 48 | - * These routes all receive session state, CSRF protection, etc. |
|
| 49 | - * |
|
| 50 | - * @return void |
|
| 51 | - */ |
|
| 52 | - protected function mapWebRoutes() |
|
| 53 | - { |
|
| 54 | - Route::group([ |
|
| 55 | - 'middleware' => 'web', |
|
| 56 | - 'namespace' => $this->namespace, |
|
| 57 | - ], function ($router) { |
|
| 58 | - require module_path('acl', 'Routes/web.php'); |
|
| 59 | - }); |
|
| 60 | - } |
|
| 45 | + /** |
|
| 46 | + * Define the "web" routes for the module. |
|
| 47 | + * |
|
| 48 | + * These routes all receive session state, CSRF protection, etc. |
|
| 49 | + * |
|
| 50 | + * @return void |
|
| 51 | + */ |
|
| 52 | + protected function mapWebRoutes() |
|
| 53 | + { |
|
| 54 | + Route::group([ |
|
| 55 | + 'middleware' => 'web', |
|
| 56 | + 'namespace' => $this->namespace, |
|
| 57 | + ], function ($router) { |
|
| 58 | + require module_path('acl', 'Routes/web.php'); |
|
| 59 | + }); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Define the "api" routes for the module. |
|
| 64 | - * |
|
| 65 | - * These routes are typically stateless. |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - */ |
|
| 69 | - protected function mapApiRoutes() |
|
| 70 | - { |
|
| 71 | - Route::group([ |
|
| 72 | - 'middleware' => 'api', |
|
| 73 | - 'namespace' => $this->namespace, |
|
| 74 | - 'prefix' => 'api', |
|
| 75 | - ], function ($router) { |
|
| 76 | - require module_path('acl', 'Routes/api.php'); |
|
| 77 | - }); |
|
| 78 | - } |
|
| 62 | + /** |
|
| 63 | + * Define the "api" routes for the module. |
|
| 64 | + * |
|
| 65 | + * These routes are typically stateless. |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + */ |
|
| 69 | + protected function mapApiRoutes() |
|
| 70 | + { |
|
| 71 | + Route::group([ |
|
| 72 | + 'middleware' => 'api', |
|
| 73 | + 'namespace' => $this->namespace, |
|
| 74 | + 'prefix' => 'api', |
|
| 75 | + ], function ($router) { |
|
| 76 | + require module_path('acl', 'Routes/api.php'); |
|
| 77 | + }); |
|
| 78 | + } |
|
| 79 | 79 | } |