Completed
Push — master ( eb2586...ec2395 )
by Sherif
01:59
created
src/Modules/Core/BaseClasses/BaseApiController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
      * Init new object.
35 35
      *
36 36
      * @param   mixed      $repo
37
-     * @param   CoreConfig $config
37
+     * @param   \App\Modules\Core\Utl\CoreConfig $config
38 38
      * @param   string     $modelResource
39 39
      * @return  void
40 40
      */
Please login to merge, or discard this patch.
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -9,205 +9,205 @@
 block discarded – undo
9 9
 
10 10
 class BaseApiController extends Controller
11 11
 {
12
-    /**
13
-     * The config implementation.
14
-     *
15
-     * @var array
16
-     */
17
-    protected $config;
18
-
19
-    /**
20
-     * The relations implementation.
21
-     *
22
-     * @var array
23
-     */
24
-    protected $relations;
25
-
26
-    /**
27
-     * The repo implementation.
28
-     *
29
-     * @var object
30
-     */
31
-    protected $repo;
32
-
33
-    /**
34
-     * Init new object.
35
-     *
36
-     * @param   mixed      $repo
37
-     * @param   CoreConfig $config
38
-     * @param   string     $modelResource
39
-     * @return  void
40
-     */
41
-    public function __construct($repo, $config, $modelResource)
42
-    {
43
-        $this->repo = $repo;
44
-        $this->modelResource = $modelResource;
45
-        $this->config = $config->getConfig();
46
-        $this->modelName = explode('\\', get_called_class());
47
-        $this->modelName = lcfirst(str_replace('Controller', '', end($this->modelName)));
48
-        $this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false;
49
-        $this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
50
-        $this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
51
-        $route = explode('@', \Route::currentRouteAction())[1];
52
-
53
-        $this->setSessions();
54
-        $this->checkPermission($route);
55
-        $this->setRelations($route);
56
-    }
57
-
58
-    /**
59
-     * Fetch all records with relations from storage.
60
-     *
61
-     * @param Request $request
62
-     * @return \Illuminate\Http\Response
63
-     */
64
-    public function index(Request $request)
65
-    {
66
-        return $this->modelResource::collection($this->repo->list($this->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc')));
67
-    }
68
-
69
-    /**
70
-     * Fetch the single object with relations from storage.
71
-     *
72
-     * @param  integer $id Id of the requested model.
73
-     * @return \Illuminate\Http\Response
74
-     */
75
-    public function find($id)
76
-    {
77
-        return new $this->modelResource($this->repo->find($id, $this->relations));
78
-    }
79
-
80
-    /**
81
-     * Delete by the given id from storage.
82
-     *
83
-     * @param  integer $id Id of the deleted model.
84
-     * @return \Illuminate\Http\Response
85
-     */
86
-    public function delete($id)
87
-    {
88
-        return new GeneralResource($this->repo->delete($id));
89
-    }
90
-
91
-    /**
92
-     * Return the deleted models in pages based on the given conditions.
93
-     *
94
-     * @param Request $request
95
-     * @return \Illuminate\Http\Response
96
-     */
97
-    public function deleted(Request $request)
98
-    {
99
-        return $this->modelResource::collection($this->repo->deleted($request->all(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc')));
100
-    }
101
-
102
-    /**
103
-     * Restore the deleted model.
104
-     *
105
-     * @param  integer $id Id of the restored model.
106
-     * @return \Illuminate\Http\Response
107
-     */
108
-    public function restore($id)
109
-    {
110
-        return new GeneralResource($this->repo->restore($id));
111
-    }
112
-
113
-    /**
114
-     * Check if the logged in user can do the given permission.
115
-     *
116
-     * @param  string $permission
117
-     * @return void
118
-     */
119
-    private function checkPermission($permission)
120
-    {
121
-        \Auth::shouldUse('api');
122
-        $this->middleware('auth:api', ['except' => $this->skipLoginCheck]);
12
+	/**
13
+	 * The config implementation.
14
+	 *
15
+	 * @var array
16
+	 */
17
+	protected $config;
18
+
19
+	/**
20
+	 * The relations implementation.
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $relations;
25
+
26
+	/**
27
+	 * The repo implementation.
28
+	 *
29
+	 * @var object
30
+	 */
31
+	protected $repo;
32
+
33
+	/**
34
+	 * Init new object.
35
+	 *
36
+	 * @param   mixed      $repo
37
+	 * @param   CoreConfig $config
38
+	 * @param   string     $modelResource
39
+	 * @return  void
40
+	 */
41
+	public function __construct($repo, $config, $modelResource)
42
+	{
43
+		$this->repo = $repo;
44
+		$this->modelResource = $modelResource;
45
+		$this->config = $config->getConfig();
46
+		$this->modelName = explode('\\', get_called_class());
47
+		$this->modelName = lcfirst(str_replace('Controller', '', end($this->modelName)));
48
+		$this->validationRules = property_exists($this, 'validationRules') ? $this->validationRules : false;
49
+		$this->skipPermissionCheck = property_exists($this, 'skipPermissionCheck') ? $this->skipPermissionCheck : [];
50
+		$this->skipLoginCheck = property_exists($this, 'skipLoginCheck') ? $this->skipLoginCheck : [];
51
+		$route = explode('@', \Route::currentRouteAction())[1];
52
+
53
+		$this->setSessions();
54
+		$this->checkPermission($route);
55
+		$this->setRelations($route);
56
+	}
57
+
58
+	/**
59
+	 * Fetch all records with relations from storage.
60
+	 *
61
+	 * @param Request $request
62
+	 * @return \Illuminate\Http\Response
63
+	 */
64
+	public function index(Request $request)
65
+	{
66
+		return $this->modelResource::collection($this->repo->list($this->relations, $request->query(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc')));
67
+	}
68
+
69
+	/**
70
+	 * Fetch the single object with relations from storage.
71
+	 *
72
+	 * @param  integer $id Id of the requested model.
73
+	 * @return \Illuminate\Http\Response
74
+	 */
75
+	public function find($id)
76
+	{
77
+		return new $this->modelResource($this->repo->find($id, $this->relations));
78
+	}
79
+
80
+	/**
81
+	 * Delete by the given id from storage.
82
+	 *
83
+	 * @param  integer $id Id of the deleted model.
84
+	 * @return \Illuminate\Http\Response
85
+	 */
86
+	public function delete($id)
87
+	{
88
+		return new GeneralResource($this->repo->delete($id));
89
+	}
90
+
91
+	/**
92
+	 * Return the deleted models in pages based on the given conditions.
93
+	 *
94
+	 * @param Request $request
95
+	 * @return \Illuminate\Http\Response
96
+	 */
97
+	public function deleted(Request $request)
98
+	{
99
+		return $this->modelResource::collection($this->repo->deleted($request->all(), $request->query('perPage'), $request->query('sortBy'), $request->query('desc')));
100
+	}
101
+
102
+	/**
103
+	 * Restore the deleted model.
104
+	 *
105
+	 * @param  integer $id Id of the restored model.
106
+	 * @return \Illuminate\Http\Response
107
+	 */
108
+	public function restore($id)
109
+	{
110
+		return new GeneralResource($this->repo->restore($id));
111
+	}
112
+
113
+	/**
114
+	 * Check if the logged in user can do the given permission.
115
+	 *
116
+	 * @param  string $permission
117
+	 * @return void
118
+	 */
119
+	private function checkPermission($permission)
120
+	{
121
+		\Auth::shouldUse('api');
122
+		$this->middleware('auth:api', ['except' => $this->skipLoginCheck]);
123 123
         
124
-        if (! in_array($permission, $this->skipLoginCheck) && $user = \Auth::user()) {
125
-            $user             = \Auth::user();
126
-            $permission       = $permission !== 'index' ? $permission : 'list';
127
-            $isPasswordClient = $user->token()->client->password_client;
128
-            $this->updateLocaleAndTimezone($user);
129
-
130
-            if ($user->blocked) {
131
-                \ErrorHandler::userIsBlocked();
132
-            }
133
-
134
-            if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->modelName))) {
135
-            } elseif (! $isPasswordClient && $user->tokenCan($this->modelName.'-'.$permission)) {
136
-            } else {
137
-                \ErrorHandler::noPermissions();
138
-            }
139
-        }
140
-    }
141
-
142
-    /**
143
-     * Set sessions based on the given headers in the request.
144
-     *
145
-     * @return void
146
-     */
147
-    private function setSessions()
148
-    {
149
-        \Session::put('time-zone', \Request::header('time-zone') ?: 0);
150
-
151
-        $locale = \Request::header('locale');
152
-        switch ($locale) {
153
-            case 'en':
154
-                \App::setLocale('en');
155
-                \Session::put('locale', 'en');
156
-                break;
157
-
158
-            case 'ar':
159
-                \App::setLocale('ar');
160
-                \Session::put('locale', 'ar');
161
-                break;
162
-
163
-            case 'all':
164
-                \App::setLocale('en');
165
-                \Session::put('locale', 'all');
166
-                break;
167
-
168
-            default:
169
-                \App::setLocale('en');
170
-                \Session::put('locale', 'en');
171
-                break;
172
-        }
173
-    }
174
-
175
-    /**
176
-     * Set relation based on the called api.
177
-     *
178
-     * @param  string $route
179
-     * @return void
180
-     */
181
-    private function setRelations($route)
182
-    {
183
-        $route           = $route !== 'index' ? $route : 'list';
184
-        $relations       = Arr::get($this->config['relations'], $this->modelName, false);
185
-        $this->relations = $relations && isset($relations[$route]) ? $relations[$route] : [];
186
-    }
187
-
188
-    /**
189
-     * Update the logged in user locale and time zone.
190
-     *
191
-     * @param  object $user
192
-     * @return void
193
-     */
194
-    private function updateLocaleAndTimezone($user)
195
-    {
196
-        $update   = false;
197
-        $locale   = \Session::get('locale');
198
-        $timezone = \Session::get('time-zone');
199
-        if ($locale && $locale !== 'all' && $locale !== $user->locale) {
200
-            $user->locale = $locale;
201
-            $update       = true;
202
-        }
203
-
204
-        if ($timezone && $timezone !== $user->timezone) {
205
-            $user->timezone = $timezone;
206
-            $update       = true;
207
-        }
208
-
209
-        if ($update) {
210
-            $user->save();
211
-        }
212
-    }
124
+		if (! in_array($permission, $this->skipLoginCheck) && $user = \Auth::user()) {
125
+			$user             = \Auth::user();
126
+			$permission       = $permission !== 'index' ? $permission : 'list';
127
+			$isPasswordClient = $user->token()->client->password_client;
128
+			$this->updateLocaleAndTimezone($user);
129
+
130
+			if ($user->blocked) {
131
+				\ErrorHandler::userIsBlocked();
132
+			}
133
+
134
+			if ($isPasswordClient && (in_array($permission, $this->skipPermissionCheck) || \Core::users()->can($permission, $this->modelName))) {
135
+			} elseif (! $isPasswordClient && $user->tokenCan($this->modelName.'-'.$permission)) {
136
+			} else {
137
+				\ErrorHandler::noPermissions();
138
+			}
139
+		}
140
+	}
141
+
142
+	/**
143
+	 * Set sessions based on the given headers in the request.
144
+	 *
145
+	 * @return void
146
+	 */
147
+	private function setSessions()
148
+	{
149
+		\Session::put('time-zone', \Request::header('time-zone') ?: 0);
150
+
151
+		$locale = \Request::header('locale');
152
+		switch ($locale) {
153
+			case 'en':
154
+				\App::setLocale('en');
155
+				\Session::put('locale', 'en');
156
+				break;
157
+
158
+			case 'ar':
159
+				\App::setLocale('ar');
160
+				\Session::put('locale', 'ar');
161
+				break;
162
+
163
+			case 'all':
164
+				\App::setLocale('en');
165
+				\Session::put('locale', 'all');
166
+				break;
167
+
168
+			default:
169
+				\App::setLocale('en');
170
+				\Session::put('locale', 'en');
171
+				break;
172
+		}
173
+	}
174
+
175
+	/**
176
+	 * Set relation based on the called api.
177
+	 *
178
+	 * @param  string $route
179
+	 * @return void
180
+	 */
181
+	private function setRelations($route)
182
+	{
183
+		$route           = $route !== 'index' ? $route : 'list';
184
+		$relations       = Arr::get($this->config['relations'], $this->modelName, false);
185
+		$this->relations = $relations && isset($relations[$route]) ? $relations[$route] : [];
186
+	}
187
+
188
+	/**
189
+	 * Update the logged in user locale and time zone.
190
+	 *
191
+	 * @param  object $user
192
+	 * @return void
193
+	 */
194
+	private function updateLocaleAndTimezone($user)
195
+	{
196
+		$update   = false;
197
+		$locale   = \Session::get('locale');
198
+		$timezone = \Session::get('time-zone');
199
+		if ($locale && $locale !== 'all' && $locale !== $user->locale) {
200
+			$user->locale = $locale;
201
+			$update       = true;
202
+		}
203
+
204
+		if ($timezone && $timezone !== $user->timezone) {
205
+			$user->timezone = $timezone;
206
+			$update       = true;
207
+		}
208
+
209
+		if ($update) {
210
+			$user->save();
211
+		}
212
+	}
213 213
 }
Please login to merge, or discard this patch.
src/Modules/Reporting/Http/Controllers/ReportController.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      *
34 34
      * @param Request $request
35 35
      * @param  string $reportName Name of the requested report
36
-     * @return \Illuminate\Http\Response
36
+     * @return \Illuminate\Http\JsonResponse
37 37
      */
38 38
     public function getReport(Request $request, $reportName)
39 39
     {
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -9,34 +9,34 @@
 block discarded – undo
9 9
 
10 10
 class ReportController extends BaseApiController
11 11
 {
12
-    /**
13
-     * List of all route actions that the base api controller
14
-     * will skip permissions check for them.
15
-     * @var array
16
-     */
17
-    protected $skipPermissionCheck = ['getReport'];
12
+	/**
13
+	 * List of all route actions that the base api controller
14
+	 * will skip permissions check for them.
15
+	 * @var array
16
+	 */
17
+	protected $skipPermissionCheck = ['getReport'];
18 18
 
19
-    /**
20
-     * Init new object.
21
-     *
22
-     * @param   ReportRepository $repo
23
-     * @param   CoreConfig       $config
24
-     * @return  void
25
-     */
26
-    public function __construct(ReportRepository $repo, CoreConfig $config)
27
-    {
28
-        parent::__construct($repo, $config, 'App\Modules\Reporting\Http\Resources\Report');
29
-    }
19
+	/**
20
+	 * Init new object.
21
+	 *
22
+	 * @param   ReportRepository $repo
23
+	 * @param   CoreConfig       $config
24
+	 * @return  void
25
+	 */
26
+	public function __construct(ReportRepository $repo, CoreConfig $config)
27
+	{
28
+		parent::__construct($repo, $config, 'App\Modules\Reporting\Http\Resources\Report');
29
+	}
30 30
 
31
-    /**
32
-     * Render the given report name with the given conditions.
33
-     *
34
-     * @param Request $request
35
-     * @param  string $reportName Name of the requested report
36
-     * @return \Illuminate\Http\Response
37
-     */
38
-    public function getReport(Request $request, $reportName)
39
-    {
40
-        return \Response::json($this->repo->getReport($reportName, $request->all(), $request->query('perPage')), 200);
41
-    }
31
+	/**
32
+	 * Render the given report name with the given conditions.
33
+	 *
34
+	 * @param Request $request
35
+	 * @param  string $reportName Name of the requested report
36
+	 * @return \Illuminate\Http\Response
37
+	 */
38
+	public function getReport(Request $request, $reportName)
39
+	{
40
+		return \Response::json($this->repo->getReport($reportName, $request->all(), $request->query('perPage')), 200);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Repositories/NotificationRepository.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -5,73 +5,73 @@
 block discarded – undo
5 5
 
6 6
 class NotificationRepository extends BaseRepository
7 7
 {
8
-    /**
9
-     * Init new object.
10
-     *
11
-     * @param   Notification $model
12
-     * @return  void
13
-     */
14
-    public function __construct(Notification $model)
15
-    {
16
-        parent::__construct($model);
17
-    }
8
+	/**
9
+	 * Init new object.
10
+	 *
11
+	 * @param   Notification $model
12
+	 * @return  void
13
+	 */
14
+	public function __construct(Notification $model)
15
+	{
16
+		parent::__construct($model);
17
+	}
18 18
 
19
-    /**
20
-     * Retrieve all notifications of the logged in user.
21
-     *
22
-     * @param  integer $perPage
23
-     * @return Collection
24
-     */
25
-    public function all($perPage)
26
-    {
27
-        return \Auth::user()->notifications()->paginate($perPage);
28
-    }
19
+	/**
20
+	 * Retrieve all notifications of the logged in user.
21
+	 *
22
+	 * @param  integer $perPage
23
+	 * @return Collection
24
+	 */
25
+	public function all($perPage)
26
+	{
27
+		return \Auth::user()->notifications()->paginate($perPage);
28
+	}
29 29
 
30
-    /**
31
-     * Retrieve unread notifications of the logged in user.
32
-     *
33
-     * @param  integer $perPage
34
-     * @return Collection
35
-     */
36
-    public function unread($perPage)
37
-    {
38
-        return \Auth::user()->unreadNotifications()->paginate($perPage);
39
-    }
30
+	/**
31
+	 * Retrieve unread notifications of the logged in user.
32
+	 *
33
+	 * @param  integer $perPage
34
+	 * @return Collection
35
+	 */
36
+	public function unread($perPage)
37
+	{
38
+		return \Auth::user()->unreadNotifications()->paginate($perPage);
39
+	}
40 40
 
41
-    /**
42
-     * Mark the notification as read.
43
-     *
44
-     * @param  integer  $id
45
-     * @return object
46
-     */
47
-    public function markAsRead($id)
48
-    {
49
-        if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) {
50
-            $notification->markAsRead();
51
-        }
52
-    }
41
+	/**
42
+	 * Mark the notification as read.
43
+	 *
44
+	 * @param  integer  $id
45
+	 * @return object
46
+	 */
47
+	public function markAsRead($id)
48
+	{
49
+		if ($notification = \Auth::user()->unreadNotifications()->where('id', $id)->first()) {
50
+			$notification->markAsRead();
51
+		}
52
+	}
53 53
 
54
-    /**
55
-     * Mark all notifications as read.
56
-     *
57
-     * @return void
58
-     */
59
-    public function markAllAsRead()
60
-    {
61
-        \Auth::user()->unreadNotifications()->update(['read_at' => now()]);
62
-    }
54
+	/**
55
+	 * Mark all notifications as read.
56
+	 *
57
+	 * @return void
58
+	 */
59
+	public function markAllAsRead()
60
+	{
61
+		\Auth::user()->unreadNotifications()->update(['read_at' => now()]);
62
+	}
63 63
 
64
-    /**
65
-     * Notify th given user with the given notification.
66
-     *
67
-     * @param  collection $users
68
-     * @param  string     $notification
69
-     * @param  object     $notificationData
70
-     * @return void
71
-     */
72
-    public function notify($users, $notification, $notificationData = false)
73
-    {
74
-        $notification = 'App\Modules\Notifications\Notifications\\'.$notification;
75
-        \Notification::send($users, new $notification($notificationData));
76
-    }
64
+	/**
65
+	 * Notify th given user with the given notification.
66
+	 *
67
+	 * @param  collection $users
68
+	 * @param  string     $notification
69
+	 * @param  object     $notificationData
70
+	 * @return void
71
+	 */
72
+	public function notify($users, $notification, $notificationData = false)
73
+	{
74
+		$notification = 'App\Modules\Notifications\Notifications\\'.$notification;
75
+		\Notification::send($users, new $notification($notificationData));
76
+	}
77 77
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Resources/Notification.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@
 block discarded – undo
6 6
 
7 7
 class Notification extends JsonResource
8 8
 {
9
-    /**
10
-     * Transform the resource into an array.
11
-     *
12
-     * @param Request $request
13
-     * @return array
14
-     */
15
-    public function toArray($request)
16
-    {
17
-        return [
18
-            'id' => $this->id,
19
-            'type' => $this->type,
20
-            'data' => $this->data,
21
-            'read_at' => $this->read_at,
22
-            'created_at' => $this->created_at,
23
-            'updated_at' => $this->updated_at,
24
-        ];
25
-    }
9
+	/**
10
+	 * Transform the resource into an array.
11
+	 *
12
+	 * @param Request $request
13
+	 * @return array
14
+	 */
15
+	public function toArray($request)
16
+	{
17
+		return [
18
+			'id' => $this->id,
19
+			'type' => $this->type,
20
+			'data' => $this->data,
21
+			'read_at' => $this->read_at,
22
+			'created_at' => $this->created_at,
23
+			'updated_at' => $this->updated_at,
24
+		];
25
+	}
26 26
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Resources/PushNotificationDevice.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@
 block discarded – undo
7 7
 
8 8
 class PushNotificationDevice extends JsonResource
9 9
 {
10
-    /**
11
-     * Transform the resource into an array.
12
-     *
13
-     * @param Request $request
14
-     * @return array
15
-     */
16
-    public function toArray($request)
17
-    {
18
-        return [
19
-            'id' => $this->id,
20
-            'device_token' => $this->device_token,
21
-            'access_token' => $this->access_token,
22
-            'user' => new UserResource($this->whenLoaded('user')),
23
-            'created_at' => $this->created_at,
24
-            'updated_at' => $this->updated_at,
25
-        ];
26
-    }
10
+	/**
11
+	 * Transform the resource into an array.
12
+	 *
13
+	 * @param Request $request
14
+	 * @return array
15
+	 */
16
+	public function toArray($request)
17
+	{
18
+		return [
19
+			'id' => $this->id,
20
+			'device_token' => $this->device_token,
21
+			'access_token' => $this->access_token,
22
+			'user' => new UserResource($this->whenLoaded('user')),
23
+			'created_at' => $this->created_at,
24
+			'updated_at' => $this->updated_at,
25
+		];
26
+	}
27 27
 }
Please login to merge, or discard this patch.
Modules/Notifications/Http/Controllers/PushNotificationDeviceController.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@
 block discarded – undo
11 11
 
12 12
 class PushNotificationDeviceController extends BaseApiController
13 13
 {
14
-    /**
15
-     * List of all route actions that the base api controller
16
-     * will skip permissions check for them.
17
-     * @var array
18
-     */
19
-    protected $skipPermissionCheck = ['registerDevice'];
14
+	/**
15
+	 * List of all route actions that the base api controller
16
+	 * will skip permissions check for them.
17
+	 * @var array
18
+	 */
19
+	protected $skipPermissionCheck = ['registerDevice'];
20 20
 
21
-    /**
22
-     * Init new object.
23
-     *
24
-     * @param   PushNotificationDeviceRepository $repo
25
-     * @param   CoreConfig                       $config
26
-     * @return  void
27
-     */
28
-    public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config)
29
-    {
30
-        parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice');
31
-    }
21
+	/**
22
+	 * Init new object.
23
+	 *
24
+	 * @param   PushNotificationDeviceRepository $repo
25
+	 * @param   CoreConfig                       $config
26
+	 * @return  void
27
+	 */
28
+	public function __construct(PushNotificationDeviceRepository $repo, CoreConfig $config)
29
+	{
30
+		parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\PushNotificationDevice');
31
+	}
32 32
 
33
-    /**
34
-     * Insert the given model to storage.
35
-     *
36
-     * @param InsertPushNotificationDevice $request
37
-     * @return \Illuminate\Http\Response
38
-     */
39
-    public function insert(InsertPushNotificationDevice $request)
40
-    {
41
-        return new $this->modelResource($this->repo->save($request->all()));
42
-    }
33
+	/**
34
+	 * Insert the given model to storage.
35
+	 *
36
+	 * @param InsertPushNotificationDevice $request
37
+	 * @return \Illuminate\Http\Response
38
+	 */
39
+	public function insert(InsertPushNotificationDevice $request)
40
+	{
41
+		return new $this->modelResource($this->repo->save($request->all()));
42
+	}
43 43
 
44
-    /**
45
-     * Update the given model to storage.
46
-     *
47
-     * @param UpdatePushNotificationDevice $request
48
-     * @return \Illuminate\Http\Response
49
-     */
50
-    public function update(UpdatePushNotificationDevice $request)
51
-    {
52
-        return new $this->modelResource($this->repo->save($request->all()));
53
-    }
44
+	/**
45
+	 * Update the given model to storage.
46
+	 *
47
+	 * @param UpdatePushNotificationDevice $request
48
+	 * @return \Illuminate\Http\Response
49
+	 */
50
+	public function update(UpdatePushNotificationDevice $request)
51
+	{
52
+		return new $this->modelResource($this->repo->save($request->all()));
53
+	}
54 54
 
55
-    /**
56
-     * Register the given device to the logged in user.
57
-     *
58
-     * @param RegisterDevice $request
59
-     * @return \Illuminate\Http\Response
60
-     */
61
-    public function registerDevice(RegisterDevice $request)
62
-    {
63
-        return new $this->modelResource($this->repo->registerDevice($request->all()));
64
-    }
55
+	/**
56
+	 * Register the given device to the logged in user.
57
+	 *
58
+	 * @param RegisterDevice $request
59
+	 * @return \Illuminate\Http\Response
60
+	 */
61
+	public function registerDevice(RegisterDevice $request)
62
+	{
63
+		return new $this->modelResource($this->repo->registerDevice($request->all()));
64
+	}
65 65
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Controllers/NotificationController.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -10,65 +10,65 @@
 block discarded – undo
10 10
 
11 11
 class NotificationController extends BaseApiController
12 12
 {
13
-    /**
14
-     * List of all route actions that the base api controller
15
-     * will skip permissions check for them.
16
-     * @var array
17
-     */
18
-    protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread'];
13
+	/**
14
+	 * List of all route actions that the base api controller
15
+	 * will skip permissions check for them.
16
+	 * @var array
17
+	 */
18
+	protected $skipPermissionCheck = ['markAsRead', 'markAllAsRead', 'index', 'unread'];
19 19
 
20
-    /**
21
-     * Init new object.
22
-     *
23
-     * @param   NotificationRepository $repo
24
-     * @param   CoreConfig             $config
25
-     * @return  void
26
-     */
27
-    public function __construct(NotificationRepository $repo, CoreConfig $config)
28
-    {
29
-        parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification');
30
-    }
20
+	/**
21
+	 * Init new object.
22
+	 *
23
+	 * @param   NotificationRepository $repo
24
+	 * @param   CoreConfig             $config
25
+	 * @return  void
26
+	 */
27
+	public function __construct(NotificationRepository $repo, CoreConfig $config)
28
+	{
29
+		parent::__construct($repo, $config, 'App\Modules\Notifications\Http\Resources\Notification');
30
+	}
31 31
 
32
-    /**
33
-     * Retrieve all notifications of the logged in user.
34
-     *
35
-     * @param Request $request
36
-     * @return \Illuminate\Http\Response
37
-     */
38
-    public function index(Request $request)
39
-    {
40
-        return $this->modelResource::collection($this->repo->all($request->query('perPage')));
41
-    }
32
+	/**
33
+	 * Retrieve all notifications of the logged in user.
34
+	 *
35
+	 * @param Request $request
36
+	 * @return \Illuminate\Http\Response
37
+	 */
38
+	public function index(Request $request)
39
+	{
40
+		return $this->modelResource::collection($this->repo->all($request->query('perPage')));
41
+	}
42 42
 
43
-    /**
44
-     * Retrieve unread notifications of the logged in user.
45
-     *
46
-     * @param Request $request
47
-     * @return \Illuminate\Http\Response
48
-     */
49
-    public function unread(Request $request)
50
-    {
51
-        return $this->modelResource::collection($this->repo->unread($request->query('perPage')));
52
-    }
43
+	/**
44
+	 * Retrieve unread notifications of the logged in user.
45
+	 *
46
+	 * @param Request $request
47
+	 * @return \Illuminate\Http\Response
48
+	 */
49
+	public function unread(Request $request)
50
+	{
51
+		return $this->modelResource::collection($this->repo->unread($request->query('perPage')));
52
+	}
53 53
 
54
-    /**
55
-     * Mark the notification as read.
56
-     *
57
-     * @param  integer  $id Id of the notification.
58
-     * @return \Illuminate\Http\Response
59
-     */
60
-    public function markAsRead($id)
61
-    {
62
-        return new GeneralResource($this->repo->markAsRead($id));
63
-    }
54
+	/**
55
+	 * Mark the notification as read.
56
+	 *
57
+	 * @param  integer  $id Id of the notification.
58
+	 * @return \Illuminate\Http\Response
59
+	 */
60
+	public function markAsRead($id)
61
+	{
62
+		return new GeneralResource($this->repo->markAsRead($id));
63
+	}
64 64
 
65
-    /**
66
-     * Mark all notifications as read.
67
-     *
68
-     * @return \Illuminate\Http\Response
69
-     */
70
-    public function markAllAsRead()
71
-    {
72
-        return new GeneralResource($this->repo->markAllAsRead());
73
-    }
65
+	/**
66
+	 * Mark all notifications as read.
67
+	 *
68
+	 * @return \Illuminate\Http\Response
69
+	 */
70
+	public function markAllAsRead()
71
+	{
72
+		return new GeneralResource($this->repo->markAllAsRead());
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Modules/Notifications/Http/Requests/InsertPushNotificationDevice copy.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class InsertPushNotificationDevice extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'device_token' => 'required|string|max:255',
28
-            'user_id'      => 'required|exists:users,id'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'device_token' => 'required|string|max:255',
28
+			'user_id'      => 'required|exists:users,id'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Notifications/Http/Requests/UpdatePushNotificationDevice.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class UpdatePushNotificationDevice extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'id'           => 'required|exists:push_notification_devices,id',
28
-            'device_token' => 'required|string|max:255',
29
-            'user_id'      => 'required|exists:users,id'
30
-        ];
31
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'id'           => 'required|exists:push_notification_devices,id',
28
+			'device_token' => 'required|string|max:255',
29
+			'user_id'      => 'required|exists:users,id'
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.