@@ -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 | } |
@@ -6,48 +6,48 @@ |
||
6 | 6 | class PushNotificationDevice extends Model |
7 | 7 | { |
8 | 8 | |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'push_notifications_devices'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at', 'access_token']; |
|
13 | - protected $guarded = ['id']; |
|
14 | - protected $fillable = ['device_token', 'user_id', 'access_token']; |
|
15 | - public $searchable = ['device_token']; |
|
16 | - |
|
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
21 | - |
|
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
26 | - |
|
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'push_notifications_devices'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at', 'access_token']; |
|
13 | + protected $guarded = ['id']; |
|
14 | + protected $fillable = ['device_token', 'user_id', 'access_token']; |
|
15 | + public $searchable = ['device_token']; |
|
16 | + |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | + |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | + |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public function user() |
|
33 | - { |
|
34 | - return $this->belongsTo('App\Modules\Acl\AclUser'); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Encrypt the access_token attribute before |
|
39 | - * saving it in the storage. |
|
40 | - * |
|
41 | - * @param string $value |
|
42 | - */ |
|
43 | - public function setLoginTokenAttribute($value) |
|
44 | - { |
|
45 | - $this->attributes['access_token'] = encrypt($value); |
|
46 | - } |
|
47 | - |
|
48 | - public static function boot() |
|
49 | - { |
|
50 | - parent::boot(); |
|
51 | - PushNotificationDevice::observe(\App::make('App\Modules\Notifications\ModelObservers\PushNotificationDeviceObserver')); |
|
52 | - } |
|
32 | + public function user() |
|
33 | + { |
|
34 | + return $this->belongsTo('App\Modules\Acl\AclUser'); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Encrypt the access_token attribute before |
|
39 | + * saving it in the storage. |
|
40 | + * |
|
41 | + * @param string $value |
|
42 | + */ |
|
43 | + public function setLoginTokenAttribute($value) |
|
44 | + { |
|
45 | + $this->attributes['access_token'] = encrypt($value); |
|
46 | + } |
|
47 | + |
|
48 | + public static function boot() |
|
49 | + { |
|
50 | + parent::boot(); |
|
51 | + PushNotificationDevice::observe(\App::make('App\Modules\Notifications\ModelObservers\PushNotificationDeviceObserver')); |
|
52 | + } |
|
53 | 53 | } |
@@ -13,27 +13,27 @@ |
||
13 | 13 | |
14 | 14 | Route::group(['prefix' => 'notifications'], function () { |
15 | 15 | |
16 | - Route::group(['prefix' => 'notifications'], function () { |
|
16 | + Route::group(['prefix' => 'notifications'], function () { |
|
17 | 17 | |
18 | - Route::get('list/{perPage?}', 'NotificationsController@list'); |
|
19 | - Route::get('unread/{perPage?}', 'NotificationsController@unread'); |
|
20 | - Route::get('markAsRead/{id}', 'NotificationsController@markAsRead'); |
|
21 | - Route::get('markAllAsRead', 'NotificationsController@markAllAsRead'); |
|
22 | - }); |
|
18 | + Route::get('list/{perPage?}', 'NotificationsController@list'); |
|
19 | + Route::get('unread/{perPage?}', 'NotificationsController@unread'); |
|
20 | + Route::get('markAsRead/{id}', 'NotificationsController@markAsRead'); |
|
21 | + Route::get('markAllAsRead', 'NotificationsController@markAllAsRead'); |
|
22 | + }); |
|
23 | 23 | |
24 | - Route::group(['prefix' => 'push_notifications_devices'], function () { |
|
24 | + Route::group(['prefix' => 'push_notifications_devices'], function () { |
|
25 | 25 | |
26 | - Route::get('list/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@index'); |
|
27 | - Route::get('find/{id}', 'PushNotificationsDevicesController@find'); |
|
28 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@search'); |
|
29 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@paginate'); |
|
30 | - Route::get('delete/{id}', 'PushNotificationsDevicesController@delete'); |
|
31 | - Route::get('restore/{id}', 'PushNotificationsDevicesController@restore'); |
|
32 | - Route::post('first', 'PushNotificationsDevicesController@first'); |
|
33 | - Route::post('findby/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@findby'); |
|
34 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@paginateby'); |
|
35 | - Route::post('save', 'PushNotificationsDevicesController@save'); |
|
36 | - Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@deleted'); |
|
37 | - Route::post('register/device', 'PushNotificationsDevicesController@registerDevice'); |
|
38 | - }); |
|
26 | + Route::get('list/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@index'); |
|
27 | + Route::get('find/{id}', 'PushNotificationsDevicesController@find'); |
|
28 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@search'); |
|
29 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@paginate'); |
|
30 | + Route::get('delete/{id}', 'PushNotificationsDevicesController@delete'); |
|
31 | + Route::get('restore/{id}', 'PushNotificationsDevicesController@restore'); |
|
32 | + Route::post('first', 'PushNotificationsDevicesController@first'); |
|
33 | + Route::post('findby/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@findby'); |
|
34 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@paginateby'); |
|
35 | + Route::post('save', 'PushNotificationsDevicesController@save'); |
|
36 | + Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@deleted'); |
|
37 | + Route::post('register/device', 'PushNotificationsDevicesController@registerDevice'); |
|
38 | + }); |
|
39 | 39 | }); |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | | |
12 | 12 | */ |
13 | 13 | |
14 | -Route::group(['prefix' => 'notifications'], function () { |
|
14 | +Route::group(['prefix' => 'notifications'], function() { |
|
15 | 15 | |
16 | - Route::group(['prefix' => 'notifications'], function () { |
|
16 | + Route::group(['prefix' => 'notifications'], function() { |
|
17 | 17 | |
18 | 18 | Route::get('list/{perPage?}', 'NotificationsController@list'); |
19 | 19 | Route::get('unread/{perPage?}', 'NotificationsController@unread'); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | Route::get('markAllAsRead', 'NotificationsController@markAllAsRead'); |
22 | 22 | }); |
23 | 23 | |
24 | - Route::group(['prefix' => 'push_notifications_devices'], function () { |
|
24 | + Route::group(['prefix' => 'push_notifications_devices'], function() { |
|
25 | 25 | |
26 | 26 | Route::get('list/{sortBy?}/{desc?}', 'PushNotificationsDevicesController@index'); |
27 | 27 | Route::get('find/{id}', 'PushNotificationsDevicesController@find'); |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class PushNotificationDeviceObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
13 | - |
|
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
18 | - |
|
19 | - public function creating($model) |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
23 | - |
|
24 | - public function created($model) |
|
25 | - { |
|
26 | - // |
|
27 | - } |
|
28 | - |
|
29 | - public function updating($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
33 | - |
|
34 | - public function updated($model) |
|
35 | - { |
|
36 | - // |
|
37 | - } |
|
38 | - |
|
39 | - public function deleting($model) |
|
40 | - { |
|
41 | - // |
|
42 | - } |
|
43 | - |
|
44 | - public function deleted($model) |
|
45 | - { |
|
46 | - // |
|
47 | - } |
|
48 | - |
|
49 | - public function restoring($model) |
|
50 | - { |
|
51 | - // |
|
52 | - } |
|
53 | - |
|
54 | - public function restored($model) |
|
55 | - { |
|
56 | - // |
|
57 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | + |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | + |
|
19 | + public function creating($model) |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | + |
|
24 | + public function created($model) |
|
25 | + { |
|
26 | + // |
|
27 | + } |
|
28 | + |
|
29 | + public function updating($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | + |
|
34 | + public function updated($model) |
|
35 | + { |
|
36 | + // |
|
37 | + } |
|
38 | + |
|
39 | + public function deleting($model) |
|
40 | + { |
|
41 | + // |
|
42 | + } |
|
43 | + |
|
44 | + public function deleted($model) |
|
45 | + { |
|
46 | + // |
|
47 | + } |
|
48 | + |
|
49 | + public function restoring($model) |
|
50 | + { |
|
51 | + // |
|
52 | + } |
|
53 | + |
|
54 | + public function restored($model) |
|
55 | + { |
|
56 | + // |
|
57 | + } |
|
58 | 58 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class NotificationObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
13 | - |
|
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
18 | - |
|
19 | - public function creating($model) |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
23 | - |
|
24 | - public function created($model) |
|
25 | - { |
|
26 | - // |
|
27 | - } |
|
28 | - |
|
29 | - public function updating($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
33 | - |
|
34 | - public function updated($model) |
|
35 | - { |
|
36 | - // |
|
37 | - } |
|
38 | - |
|
39 | - public function deleting($model) |
|
40 | - { |
|
41 | - // |
|
42 | - } |
|
43 | - |
|
44 | - public function deleted($model) |
|
45 | - { |
|
46 | - // |
|
47 | - } |
|
48 | - |
|
49 | - public function restoring($model) |
|
50 | - { |
|
51 | - // |
|
52 | - } |
|
53 | - |
|
54 | - public function restored($model) |
|
55 | - { |
|
56 | - // |
|
57 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | + |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | + |
|
19 | + public function creating($model) |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | + |
|
24 | + public function created($model) |
|
25 | + { |
|
26 | + // |
|
27 | + } |
|
28 | + |
|
29 | + public function updating($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | + |
|
34 | + public function updated($model) |
|
35 | + { |
|
36 | + // |
|
37 | + } |
|
38 | + |
|
39 | + public function deleting($model) |
|
40 | + { |
|
41 | + // |
|
42 | + } |
|
43 | + |
|
44 | + public function deleted($model) |
|
45 | + { |
|
46 | + // |
|
47 | + } |
|
48 | + |
|
49 | + public function restoring($model) |
|
50 | + { |
|
51 | + // |
|
52 | + } |
|
53 | + |
|
54 | + public function restored($model) |
|
55 | + { |
|
56 | + // |
|
57 | + } |
|
58 | 58 | } |
@@ -4,72 +4,72 @@ |
||
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)->first()) { |
|
48 | - $notification->markAsRead(); |
|
49 | - } |
|
50 | - } |
|
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)->first()) { |
|
48 | + $notification->markAsRead(); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Mark all notifications as read. |
|
54 | - * |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function markAllAsRead() |
|
58 | - { |
|
59 | - \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
60 | - } |
|
52 | + /** |
|
53 | + * Mark all notifications as read. |
|
54 | + * |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function markAllAsRead() |
|
58 | + { |
|
59 | + \Auth::user()->unreadNotifications()->update(['read_at' => now()]); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Notify th given user with the given notification. |
|
64 | - * |
|
65 | - * @param collection $users |
|
66 | - * @param string $notification |
|
67 | - * @param object $notificationData |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public function notify($users, $notification, $notificationData = false) |
|
71 | - { |
|
72 | - $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
73 | - \Notification::send($users, new $notification($notificationData)); |
|
74 | - } |
|
62 | + /** |
|
63 | + * Notify th given user with the given notification. |
|
64 | + * |
|
65 | + * @param collection $users |
|
66 | + * @param string $notification |
|
67 | + * @param object $notificationData |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public function notify($users, $notification, $notificationData = false) |
|
71 | + { |
|
72 | + $notification = 'App\Modules\Notifications\Notifications\\'.$notification; |
|
73 | + \Notification::send($users, new $notification($notificationData)); |
|
74 | + } |
|
75 | 75 | } |
@@ -7,59 +7,59 @@ |
||
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 | - } |
|
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 | 19 | |
20 | - /** |
|
21 | - * Register the given device to the logged in user. |
|
22 | - * |
|
23 | - * @param array $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 | - $device = $this->model->where('device_token', $data['device_token'])-> |
|
31 | - where('user_id', $data['user_id'])-> |
|
32 | - first(); |
|
20 | + /** |
|
21 | + * Register the given device to the logged in user. |
|
22 | + * |
|
23 | + * @param array $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 | + $device = $this->model->where('device_token', $data['device_token'])-> |
|
31 | + where('user_id', $data['user_id'])-> |
|
32 | + first(); |
|
33 | 33 | |
34 | - if ($device) { |
|
35 | - $data['id'] = $device->id; |
|
36 | - } |
|
34 | + if ($device) { |
|
35 | + $data['id'] = $device->id; |
|
36 | + } |
|
37 | 37 | |
38 | - return $this->save($data); |
|
39 | - } |
|
38 | + return $this->save($data); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Generate the given message data. |
|
43 | - * |
|
44 | - * @param string $title |
|
45 | - * @param string $message |
|
46 | - * @param array $data |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function generateMessageData($title, $message, $data = []) |
|
50 | - { |
|
51 | - $optionBuilder = new OptionsBuilder(); |
|
52 | - $notificationBuilder = new PayloadNotificationBuilder($title); |
|
53 | - $dataBuilder = new PayloadDataBuilder(); |
|
41 | + /** |
|
42 | + * Generate the given message data. |
|
43 | + * |
|
44 | + * @param string $title |
|
45 | + * @param string $message |
|
46 | + * @param array $data |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function generateMessageData($title, $message, $data = []) |
|
50 | + { |
|
51 | + $optionBuilder = new OptionsBuilder(); |
|
52 | + $notificationBuilder = new PayloadNotificationBuilder($title); |
|
53 | + $dataBuilder = new PayloadDataBuilder(); |
|
54 | 54 | |
55 | - $optionBuilder->setTimeToLive(60 * 20); |
|
56 | - $notificationBuilder->setBody($message); |
|
57 | - $dataBuilder->addData($data); |
|
55 | + $optionBuilder->setTimeToLive(60 * 20); |
|
56 | + $notificationBuilder->setBody($message); |
|
57 | + $dataBuilder->addData($data); |
|
58 | 58 | |
59 | - $options = $optionBuilder->build(); |
|
60 | - $notification = $notificationBuilder->build(); |
|
61 | - $data = $dataBuilder->build(); |
|
59 | + $options = $optionBuilder->build(); |
|
60 | + $notification = $notificationBuilder->build(); |
|
61 | + $data = $dataBuilder->build(); |
|
62 | 62 | |
63 | - return compact('options', 'notification', 'data'); |
|
64 | - } |
|
63 | + return compact('options', 'notification', 'data'); |
|
64 | + } |
|
65 | 65 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $factory->define(App\Modules\Reporting\Report::class, function (Faker\Generator $faker) { |
4 | - return [ |
|
5 | - 'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']), |
|
6 | - 'view_name' => $faker->word(), |
|
7 | - 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | - 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | - ]; |
|
4 | + return [ |
|
5 | + 'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']), |
|
6 | + 'view_name' => $faker->word(), |
|
7 | + 'created_at' => $faker->dateTimeBetween('-1 years', 'now'), |
|
8 | + 'updated_at' => $faker->dateTimeBetween('-1 years', 'now') |
|
9 | + ]; |
|
10 | 10 | }); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$factory->define(App\Modules\Reporting\Report::class, function (Faker\Generator $faker) { |
|
3 | +$factory->define(App\Modules\Reporting\Report::class, function(Faker\Generator $faker) { |
|
4 | 4 | return [ |
5 | 5 | 'report_name' => $faker->randomElement(['Users Count', 'Low Stock Products', 'Active Users']), |
6 | 6 | 'view_name' => $faker->word(), |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | |
6 | 6 | class SampelReport extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - DB::statement("CREATE VIEW admin_count AS |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + DB::statement("CREATE VIEW admin_count AS |
|
16 | 16 | select count(u.id) |
17 | 17 | from users u, groups g ,users_groups ug |
18 | 18 | where |
@@ -20,25 +20,25 @@ discard block |
||
20 | 20 | ug.group_id = g.id |
21 | 21 | "); |
22 | 22 | |
23 | - DB::table('reports')->insert( |
|
24 | - [ |
|
25 | - [ |
|
26 | - 'report_name' => 'admin_count', |
|
27 | - 'view_name' => 'admin_count', |
|
28 | - 'created_at' => \DB::raw('NOW()'), |
|
29 | - 'updated_at' => \DB::raw('NOW()') |
|
30 | - ] |
|
31 | - ] |
|
32 | - ); |
|
33 | - } |
|
23 | + DB::table('reports')->insert( |
|
24 | + [ |
|
25 | + [ |
|
26 | + 'report_name' => 'admin_count', |
|
27 | + 'view_name' => 'admin_count', |
|
28 | + 'created_at' => \DB::raw('NOW()'), |
|
29 | + 'updated_at' => \DB::raw('NOW()') |
|
30 | + ] |
|
31 | + ] |
|
32 | + ); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Reverse the migrations. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function down() |
|
41 | - { |
|
42 | - DB::statement("DROP VIEW IF EXISTS admin_count"); |
|
43 | - } |
|
35 | + /** |
|
36 | + * Reverse the migrations. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function down() |
|
41 | + { |
|
42 | + DB::statement("DROP VIEW IF EXISTS admin_count"); |
|
43 | + } |
|
44 | 44 | } |