Completed
Push — master ( 5050df...77fab1 )
by Sherif
01:58
created
PushNotificationDevices/Repositories/PushNotificationDeviceRepository.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
      * Register the given device to the logged in user.
22 22
      *
23 23
      * @param  array $data
24
-     * @return void
24
+     * @return boolean
25 25
      */
26 26
     public function registerDevice($data)
27 27
     {
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,60 +8,60 @@
 block discarded – undo
8 8
 
9 9
 class PushNotificationDeviceRepository extends BaseRepository
10 10
 {
11
-    /**
12
-     * Init new object.
13
-     *
14
-     * @param   PushNotificationDevice $model
15
-     * @return  void
16
-     */
17
-    public function __construct(PushNotificationDevice $model)
18
-    {
19
-        parent::__construct($model);
20
-    }
11
+	/**
12
+	 * Init new object.
13
+	 *
14
+	 * @param   PushNotificationDevice $model
15
+	 * @return  void
16
+	 */
17
+	public function __construct(PushNotificationDevice $model)
18
+	{
19
+		parent::__construct($model);
20
+	}
21 21
 
22
-    /**
23
-     * Register the given device to the logged in user.
24
-     *
25
-     * @param  array $data
26
-     * @return void
27
-     */
28
-    public function registerDevice($data)
29
-    {
30
-        $data['access_token'] = \Auth::user()->token();
31
-        $data['user_id']      = \Auth::id();
32
-        $device               = $this->model->where('device_token', $data['device_token'])->
33
-                                              where('user_id', $data['user_id'])->
34
-                                              first();
22
+	/**
23
+	 * Register the given device to the logged in user.
24
+	 *
25
+	 * @param  array $data
26
+	 * @return void
27
+	 */
28
+	public function registerDevice($data)
29
+	{
30
+		$data['access_token'] = \Auth::user()->token();
31
+		$data['user_id']      = \Auth::id();
32
+		$device               = $this->model->where('device_token', $data['device_token'])->
33
+											  where('user_id', $data['user_id'])->
34
+											  first();
35 35
 
36
-        if ($device) {
37
-            $data['id'] = $device->id;
38
-        }
36
+		if ($device) {
37
+			$data['id'] = $device->id;
38
+		}
39 39
 
40
-        return $this->save($data);
41
-    }
40
+		return $this->save($data);
41
+	}
42 42
 
43
-    /**
44
-     * Generate the given message data.
45
-     *
46
-     * @param  string $title
47
-     * @param  string $message
48
-     * @param  array  $data
49
-     * @return void
50
-     */
51
-    public function generateMessageData($title, $message, $data = [])
52
-    {
53
-        $optionBuilder       = new OptionsBuilder();
54
-        $notificationBuilder = new PayloadNotificationBuilder($title);
55
-        $dataBuilder         = new PayloadDataBuilder();
43
+	/**
44
+	 * Generate the given message data.
45
+	 *
46
+	 * @param  string $title
47
+	 * @param  string $message
48
+	 * @param  array  $data
49
+	 * @return void
50
+	 */
51
+	public function generateMessageData($title, $message, $data = [])
52
+	{
53
+		$optionBuilder       = new OptionsBuilder();
54
+		$notificationBuilder = new PayloadNotificationBuilder($title);
55
+		$dataBuilder         = new PayloadDataBuilder();
56 56
 
57
-        $optionBuilder->setTimeToLive(60 * 20);
58
-        $notificationBuilder->setBody($message);
59
-        $dataBuilder->addData($data);
57
+		$optionBuilder->setTimeToLive(60 * 20);
58
+		$notificationBuilder->setBody($message);
59
+		$dataBuilder->addData($data);
60 60
 
61
-        $options             = $optionBuilder->build();
62
-        $notification        = $notificationBuilder->build();
63
-        $data                = $dataBuilder->build();
61
+		$options             = $optionBuilder->build();
62
+		$notification        = $notificationBuilder->build();
63
+		$data                = $dataBuilder->build();
64 64
 
65
-        return compact('options', 'notification', 'data');
66
-    }
65
+		return compact('options', 'notification', 'data');
66
+	}
67 67
 }
Please login to merge, or discard this patch.
src/Modules/PushNotificationDevices/Routes/api.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use Illuminate\Http\Request;
4
-
5 3
 /*
6 4
 |--------------------------------------------------------------------------
7 5
 | API Routes
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 |
14 14
 */
15 15
 
16
-Route::group(['prefix' => 'push/notification/devices'], function () {
16
+Route::group(['prefix' => 'push/notification/devices'], function() {
17 17
         
18 18
     Route::get('/', 'PushNotificationDeviceController@index');
19 19
     Route::get('/{id}', 'PushNotificationDeviceController@find');
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
 
16 16
 Route::group(['prefix' => 'push/notification/devices'], function () {
17 17
         
18
-    Route::get('/', 'PushNotificationDeviceController@index');
19
-    Route::get('/{id}', 'PushNotificationDeviceController@find');
20
-    Route::post('/', 'PushNotificationDeviceController@insert');
21
-    Route::put('/', 'PushNotificationDeviceController@update');
22
-    Route::delete('/{id}', 'PushNotificationDeviceController@delete');
23
-    Route::get('list/deleted', 'PushNotificationDeviceController@deleted');
24
-    Route::patch('restore/{id}', 'PushNotificationDeviceController@restore');
25
-    Route::post('register/device', 'PushNotificationDeviceController@registerDevice');
18
+	Route::get('/', 'PushNotificationDeviceController@index');
19
+	Route::get('/{id}', 'PushNotificationDeviceController@find');
20
+	Route::post('/', 'PushNotificationDeviceController@insert');
21
+	Route::put('/', 'PushNotificationDeviceController@update');
22
+	Route::delete('/{id}', 'PushNotificationDeviceController@delete');
23
+	Route::get('list/deleted', 'PushNotificationDeviceController@deleted');
24
+	Route::patch('restore/{id}', 'PushNotificationDeviceController@restore');
25
+	Route::post('register/device', 'PushNotificationDeviceController@registerDevice');
26 26
 });
Please login to merge, or discard this patch.
src/Modules/Users/Reppsitories/UserRepository.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @param  array   $credentials
146 146
      * @param  boolean $skipConfirmEmail
147
-     * @return array
147
+     * @return boolean
148 148
      */
149 149
     public function register($credentials, $skipConfirmEmail = false)
150 150
     {
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      * Save the given data to the logged in user.
345 345
      *
346 346
      * @param  array $data
347
-     * @return void
347
+     * @return boolean
348 348
      */
349 349
     public function saveProfile($data)
350 350
     {
Please login to merge, or discard this patch.
Indentation   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -6,391 +6,391 @@
 block discarded – undo
6 6
 
7 7
 class UserRepository extends BaseRepository
8 8
 {
9
-    /**
10
-     * Init new object.
11
-     *
12
-     * @param   AclUser $model
13
-     * @return  void
14
-     */
15
-    public function __construct(AclUser $model)
16
-    {
17
-        parent::__construct($model);
18
-    }
19
-
20
-    /**
21
-     * Return the logged in user account.
22
-     *
23
-     * @param  array   $relations
24
-     * @return boolean
25
-     */
26
-    public function account($relations = [])
27
-    {
28
-        $permissions = [];
29
-        $user        = $this->find(\Auth::id(), $relations);
30
-        foreach ($user->roles()->get() as $role) {
31
-            $role->permissions->each(function ($permission) use (&$permissions) {
32
-                $permissions[$permission->model][$permission->id] = $permission->name;
33
-            });
34
-        }
35
-        $user->permissions = $permissions;
36
-
37
-        return $user;
38
-    }
39
-
40
-    /**
41
-     * Check if the logged in user or the given user
42
-     * has the given permissions on the given model.
43
-     *
44
-     * @param  string $nameOfPermission
45
-     * @param  string $model
46
-     * @param  mixed  $user
47
-     * @return boolean
48
-     */
49
-    public function can($nameOfPermission, $model, $user = false)
50
-    {
51
-        $user        = $user ?: $this->find(\Auth::id(), ['roles.permissions']);
52
-        $permissions = [];
53
-
54
-        $user->roles->pluck('permissions')->each(function ($permission) use (&$permissions, $model) {
55
-            $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray());
56
-        });
57
-
58
-        return in_array($nameOfPermission, $permissions);
59
-    }
60
-
61
-    /**
62
-     * Check if the logged in user has the given role.
63
-     *
64
-     * @param  string[] $roles
65
-     * @param  mixed $user
66
-     * @return boolean
67
-     */
68
-    public function hasRole($roles, $user = false)
69
-    {
70
-        $user = $user ?: $this->find(\Auth::id());
71
-        return $user->roles->whereIn('name', $roles)->count() ? true : false;
72
-    }
73
-
74
-    /**
75
-     * Assign the given role ids to the given user.
76
-     *
77
-     * @param  integer $userId
78
-     * @param  array   $roleIds
79
-     * @return object
80
-     */
81
-    public function assignRoles($userId, $roleIds)
82
-    {
83
-        \DB::transaction(function () use ($userId, $roleIds) {
84
-            $user = $this->find($userId);
85
-            $user->roles()->detach();
86
-            $user->roles()->attach($roleIds);
87
-        });
88
-
89
-        return $this->find($userId);
90
-    }
91
-
92
-
93
-    /**
94
-     * Handle a login request to the application.
95
-     *
96
-     * @param  array   $credentials
97
-     * @param  boolean $adminLogin
98
-     * @return object
99
-     */
100
-    public function login($credentials, $adminLogin = false)
101
-    {
102
-        if (! $user = $this->first(['email' => $credentials['email']])) {
103
-            \ErrorHandler::loginFailed();
104
-        } elseif ($adminLogin && ! $user->roles->whereIn('name', ['Admin'])->count()) {
105
-            \ErrorHandler::loginFailed();
106
-        } elseif (! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) {
107
-            \ErrorHandler::loginFailed();
108
-        } elseif ($user->blocked) {
109
-            \ErrorHandler::userIsBlocked();
110
-        } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
111
-            \ErrorHandler::emailNotConfirmed();
112
-        }
113
-
114
-        return $user;
115
-    }
116
-
117
-    /**
118
-     * Handle a social login request of the none admin to the application.
119
-     *
120
-     * @param  string $authCode
121
-     * @param  string $accessToken
122
-     * @param  string $type
123
-     * @return array
124
-     */
125
-    public function loginSocial($authCode, $accessToken, $type)
126
-    {
127
-        $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
128
-        $user         = \Socialite::driver($type)->userFromToken($access_token);
129
-
130
-        if (! $user->email) {
131
-            \ErrorHandler::noSocialEmail();
132
-        }
133
-
134
-        if (! $this->model->where('email', $user->email)->first()) {
135
-            $this->register(['email' => $user->email, 'password' => ''], true);
136
-        }
137
-
138
-        $loginProxy = \App::make('App\Modules\Users\Proxy\LoginProxy');
139
-        return $loginProxy->login(['email' => $user->email, 'password' => config('skeleton.social_pass')], 0);
140
-    }
9
+	/**
10
+	 * Init new object.
11
+	 *
12
+	 * @param   AclUser $model
13
+	 * @return  void
14
+	 */
15
+	public function __construct(AclUser $model)
16
+	{
17
+		parent::__construct($model);
18
+	}
19
+
20
+	/**
21
+	 * Return the logged in user account.
22
+	 *
23
+	 * @param  array   $relations
24
+	 * @return boolean
25
+	 */
26
+	public function account($relations = [])
27
+	{
28
+		$permissions = [];
29
+		$user        = $this->find(\Auth::id(), $relations);
30
+		foreach ($user->roles()->get() as $role) {
31
+			$role->permissions->each(function ($permission) use (&$permissions) {
32
+				$permissions[$permission->model][$permission->id] = $permission->name;
33
+			});
34
+		}
35
+		$user->permissions = $permissions;
36
+
37
+		return $user;
38
+	}
39
+
40
+	/**
41
+	 * Check if the logged in user or the given user
42
+	 * has the given permissions on the given model.
43
+	 *
44
+	 * @param  string $nameOfPermission
45
+	 * @param  string $model
46
+	 * @param  mixed  $user
47
+	 * @return boolean
48
+	 */
49
+	public function can($nameOfPermission, $model, $user = false)
50
+	{
51
+		$user        = $user ?: $this->find(\Auth::id(), ['roles.permissions']);
52
+		$permissions = [];
53
+
54
+		$user->roles->pluck('permissions')->each(function ($permission) use (&$permissions, $model) {
55
+			$permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray());
56
+		});
57
+
58
+		return in_array($nameOfPermission, $permissions);
59
+	}
60
+
61
+	/**
62
+	 * Check if the logged in user has the given role.
63
+	 *
64
+	 * @param  string[] $roles
65
+	 * @param  mixed $user
66
+	 * @return boolean
67
+	 */
68
+	public function hasRole($roles, $user = false)
69
+	{
70
+		$user = $user ?: $this->find(\Auth::id());
71
+		return $user->roles->whereIn('name', $roles)->count() ? true : false;
72
+	}
73
+
74
+	/**
75
+	 * Assign the given role ids to the given user.
76
+	 *
77
+	 * @param  integer $userId
78
+	 * @param  array   $roleIds
79
+	 * @return object
80
+	 */
81
+	public function assignRoles($userId, $roleIds)
82
+	{
83
+		\DB::transaction(function () use ($userId, $roleIds) {
84
+			$user = $this->find($userId);
85
+			$user->roles()->detach();
86
+			$user->roles()->attach($roleIds);
87
+		});
88
+
89
+		return $this->find($userId);
90
+	}
91
+
92
+
93
+	/**
94
+	 * Handle a login request to the application.
95
+	 *
96
+	 * @param  array   $credentials
97
+	 * @param  boolean $adminLogin
98
+	 * @return object
99
+	 */
100
+	public function login($credentials, $adminLogin = false)
101
+	{
102
+		if (! $user = $this->first(['email' => $credentials['email']])) {
103
+			\ErrorHandler::loginFailed();
104
+		} elseif ($adminLogin && ! $user->roles->whereIn('name', ['Admin'])->count()) {
105
+			\ErrorHandler::loginFailed();
106
+		} elseif (! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) {
107
+			\ErrorHandler::loginFailed();
108
+		} elseif ($user->blocked) {
109
+			\ErrorHandler::userIsBlocked();
110
+		} elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
111
+			\ErrorHandler::emailNotConfirmed();
112
+		}
113
+
114
+		return $user;
115
+	}
116
+
117
+	/**
118
+	 * Handle a social login request of the none admin to the application.
119
+	 *
120
+	 * @param  string $authCode
121
+	 * @param  string $accessToken
122
+	 * @param  string $type
123
+	 * @return array
124
+	 */
125
+	public function loginSocial($authCode, $accessToken, $type)
126
+	{
127
+		$access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
128
+		$user         = \Socialite::driver($type)->userFromToken($access_token);
129
+
130
+		if (! $user->email) {
131
+			\ErrorHandler::noSocialEmail();
132
+		}
133
+
134
+		if (! $this->model->where('email', $user->email)->first()) {
135
+			$this->register(['email' => $user->email, 'password' => ''], true);
136
+		}
137
+
138
+		$loginProxy = \App::make('App\Modules\Users\Proxy\LoginProxy');
139
+		return $loginProxy->login(['email' => $user->email, 'password' => config('skeleton.social_pass')], 0);
140
+	}
141 141
     
142
-    /**
143
-     * Handle a registration request.
144
-     *
145
-     * @param  array   $credentials
146
-     * @param  boolean $skipConfirmEmail
147
-     * @return array
148
-     */
149
-    public function register($credentials, $skipConfirmEmail = false)
150
-    {
151
-        $user = $this->save($credentials);
152
-
153
-        if ($skipConfirmEmail) {
154
-            $user->confirmed = 1;
155
-            $user->save();
156
-        } elseif (! config('skeleton.disable_confirm_email')) {
157
-            $this->sendConfirmationEmail($user->email);
158
-        }
159
-
160
-        return $user;
161
-    }
142
+	/**
143
+	 * Handle a registration request.
144
+	 *
145
+	 * @param  array   $credentials
146
+	 * @param  boolean $skipConfirmEmail
147
+	 * @return array
148
+	 */
149
+	public function register($credentials, $skipConfirmEmail = false)
150
+	{
151
+		$user = $this->save($credentials);
152
+
153
+		if ($skipConfirmEmail) {
154
+			$user->confirmed = 1;
155
+			$user->save();
156
+		} elseif (! config('skeleton.disable_confirm_email')) {
157
+			$this->sendConfirmationEmail($user->email);
158
+		}
159
+
160
+		return $user;
161
+	}
162 162
     
163
-    /**
164
-     * Block the user.
165
-     *
166
-     * @param  integer $userId
167
-     * @return object
168
-     */
169
-    public function block($userId)
170
-    {
171
-        if (! $user = $this->find($userId)) {
172
-            \ErrorHandler::notFound('user');
173
-        }
174
-        if (! $this->hasRole(['Admin'])) {
175
-            \ErrorHandler::noPermissions();
176
-        } elseif (\Auth::id() == $userId) {
177
-            \ErrorHandler::noPermissions();
178
-        } elseif ($user->roles->pluck('name')->search('Admin', true) !== false) {
179
-            \ErrorHandler::noPermissions();
180
-        }
181
-
182
-        $user->blocked = 1;
183
-        $user->save();
163
+	/**
164
+	 * Block the user.
165
+	 *
166
+	 * @param  integer $userId
167
+	 * @return object
168
+	 */
169
+	public function block($userId)
170
+	{
171
+		if (! $user = $this->find($userId)) {
172
+			\ErrorHandler::notFound('user');
173
+		}
174
+		if (! $this->hasRole(['Admin'])) {
175
+			\ErrorHandler::noPermissions();
176
+		} elseif (\Auth::id() == $userId) {
177
+			\ErrorHandler::noPermissions();
178
+		} elseif ($user->roles->pluck('name')->search('Admin', true) !== false) {
179
+			\ErrorHandler::noPermissions();
180
+		}
181
+
182
+		$user->blocked = 1;
183
+		$user->save();
184 184
         
185
-        return $user;
186
-    }
187
-
188
-    /**
189
-     * Unblock the user.
190
-     *
191
-     * @param  integer $userId
192
-     * @return object
193
-     */
194
-    public function unblock($userId)
195
-    {
196
-        if (! $this->hasRole(['Admin'])) {
197
-            \ErrorHandler::noPermissions();
198
-        }
199
-
200
-        $user          = $this->find($userId);
201
-        $user->blocked = 0;
202
-        $user->save();
203
-
204
-        return $user;
205
-    }
206
-
207
-    /**
208
-     * Send a reset link to the given user.
209
-     *
210
-     * @param  string  $email
211
-     * @return void
212
-     */
213
-    public function sendReset($email)
214
-    {
215
-        if (! $user = $this->model->where('email', $email)->first()) {
216
-            \ErrorHandler::notFound('email');
217
-        }
218
-
219
-        $token = \Password::getRepository()->create($user);
220
-        \Core::notifications()->notify($user, 'ResetPassword', $token);
221
-    }
222
-
223
-    /**
224
-     * Reset the given user's password.
225
-     *
226
-     * @param  array  $credentials
227
-     * @return string|null
228
-     */
229
-    public function resetPassword($credentials)
230
-    {
231
-        $response = \Password::reset($credentials, function ($user, $password) {
232
-            $user->password = $password;
233
-            $user->save();
234
-        });
235
-
236
-        switch ($response) {
237
-            case \Password::PASSWORD_RESET:
238
-                return 'success';
239
-
240
-            case \Password::INVALID_TOKEN:
241
-                \ErrorHandler::invalidResetToken('token');
242
-                //no break
243
-
244
-            case \Password::INVALID_PASSWORD:
245
-                \ErrorHandler::invalidResetPassword('email');
246
-                //no break
247
-
248
-            case \Password::INVALID_USER:
249
-                \ErrorHandler::notFound('user');
250
-                //no break
251
-
252
-            default:
253
-                \ErrorHandler::generalError();
254
-        }
255
-    }
256
-
257
-    /**
258
-     * Change the logged in user password.
259
-     *
260
-     * @param  array  $credentials
261
-     * @return void
262
-     */
263
-    public function changePassword($credentials)
264
-    {
265
-        $user = \Auth::user();
266
-        if (! \Hash::check($credentials['old_password'], $user->password)) {
267
-            \ErrorHandler::invalidOldPassword();
268
-        }
269
-
270
-        $user->password = $credentials['password'];
271
-        $user->save();
272
-    }
273
-
274
-    /**
275
-     * Confirm email using the confirmation code.
276
-     *
277
-     * @param  string $confirmationCode
278
-     * @return void
279
-     */
280
-    public function confirmEmail($confirmationCode)
281
-    {
282
-        if (! $user = $this->first(['confirmation_code' => $confirmationCode])) {
283
-            \ErrorHandler::invalidConfirmationCode();
284
-        }
285
-
286
-        $user->confirmed         = 1;
287
-        $user->confirmation_code = null;
288
-        $user->save();
289
-    }
290
-
291
-    /**
292
-     * Send the confirmation mail.
293
-     *
294
-     * @param  string $email
295
-     * @return void
296
-     */
297
-    public function sendConfirmationEmail($email)
298
-    {
299
-        $user = $this->first(['email' => $email]);
300
-        if ($user->confirmed) {
301
-            \ErrorHandler::emailAlreadyConfirmed();
302
-        }
303
-
304
-        $user->confirmed         = 0;
305
-        $user->confirmation_code = sha1(microtime());
306
-        $user->save();
307
-        \Core::notifications()->notify($user, 'ConfirmEmail');
308
-    }
309
-
310
-    /**
311
-     * Paginate all users in the given role based on the given conditions.
312
-     *
313
-     * @param  string  $roleName
314
-     * @param  array   $relations
315
-     * @param  integer $perPage
316
-     * @param  string  $sortBy
317
-     * @param  boolean $desc
318
-     * @return \Illuminate\Http\Response
319
-     */
320
-    public function role($conditions, $roleName, $relations, $perPage, $sortBy, $desc)
321
-    {
322
-        unset($conditions['page']);
323
-        $conditions = $this->constructConditions($conditions, $this->model);
324
-        $sort       = $desc ? 'desc' : 'asc';
325
-        $model      = $this->model->with($relations);
326
-
327
-        $model->whereHas('roles', function ($q) use ($roleName) {
328
-            $q->where('name', $roleName);
329
-        });
185
+		return $user;
186
+	}
187
+
188
+	/**
189
+	 * Unblock the user.
190
+	 *
191
+	 * @param  integer $userId
192
+	 * @return object
193
+	 */
194
+	public function unblock($userId)
195
+	{
196
+		if (! $this->hasRole(['Admin'])) {
197
+			\ErrorHandler::noPermissions();
198
+		}
199
+
200
+		$user          = $this->find($userId);
201
+		$user->blocked = 0;
202
+		$user->save();
203
+
204
+		return $user;
205
+	}
206
+
207
+	/**
208
+	 * Send a reset link to the given user.
209
+	 *
210
+	 * @param  string  $email
211
+	 * @return void
212
+	 */
213
+	public function sendReset($email)
214
+	{
215
+		if (! $user = $this->model->where('email', $email)->first()) {
216
+			\ErrorHandler::notFound('email');
217
+		}
218
+
219
+		$token = \Password::getRepository()->create($user);
220
+		\Core::notifications()->notify($user, 'ResetPassword', $token);
221
+	}
222
+
223
+	/**
224
+	 * Reset the given user's password.
225
+	 *
226
+	 * @param  array  $credentials
227
+	 * @return string|null
228
+	 */
229
+	public function resetPassword($credentials)
230
+	{
231
+		$response = \Password::reset($credentials, function ($user, $password) {
232
+			$user->password = $password;
233
+			$user->save();
234
+		});
235
+
236
+		switch ($response) {
237
+			case \Password::PASSWORD_RESET:
238
+				return 'success';
239
+
240
+			case \Password::INVALID_TOKEN:
241
+				\ErrorHandler::invalidResetToken('token');
242
+				//no break
243
+
244
+			case \Password::INVALID_PASSWORD:
245
+				\ErrorHandler::invalidResetPassword('email');
246
+				//no break
247
+
248
+			case \Password::INVALID_USER:
249
+				\ErrorHandler::notFound('user');
250
+				//no break
251
+
252
+			default:
253
+				\ErrorHandler::generalError();
254
+		}
255
+	}
256
+
257
+	/**
258
+	 * Change the logged in user password.
259
+	 *
260
+	 * @param  array  $credentials
261
+	 * @return void
262
+	 */
263
+	public function changePassword($credentials)
264
+	{
265
+		$user = \Auth::user();
266
+		if (! \Hash::check($credentials['old_password'], $user->password)) {
267
+			\ErrorHandler::invalidOldPassword();
268
+		}
269
+
270
+		$user->password = $credentials['password'];
271
+		$user->save();
272
+	}
273
+
274
+	/**
275
+	 * Confirm email using the confirmation code.
276
+	 *
277
+	 * @param  string $confirmationCode
278
+	 * @return void
279
+	 */
280
+	public function confirmEmail($confirmationCode)
281
+	{
282
+		if (! $user = $this->first(['confirmation_code' => $confirmationCode])) {
283
+			\ErrorHandler::invalidConfirmationCode();
284
+		}
285
+
286
+		$user->confirmed         = 1;
287
+		$user->confirmation_code = null;
288
+		$user->save();
289
+	}
290
+
291
+	/**
292
+	 * Send the confirmation mail.
293
+	 *
294
+	 * @param  string $email
295
+	 * @return void
296
+	 */
297
+	public function sendConfirmationEmail($email)
298
+	{
299
+		$user = $this->first(['email' => $email]);
300
+		if ($user->confirmed) {
301
+			\ErrorHandler::emailAlreadyConfirmed();
302
+		}
303
+
304
+		$user->confirmed         = 0;
305
+		$user->confirmation_code = sha1(microtime());
306
+		$user->save();
307
+		\Core::notifications()->notify($user, 'ConfirmEmail');
308
+	}
309
+
310
+	/**
311
+	 * Paginate all users in the given role based on the given conditions.
312
+	 *
313
+	 * @param  string  $roleName
314
+	 * @param  array   $relations
315
+	 * @param  integer $perPage
316
+	 * @param  string  $sortBy
317
+	 * @param  boolean $desc
318
+	 * @return \Illuminate\Http\Response
319
+	 */
320
+	public function role($conditions, $roleName, $relations, $perPage, $sortBy, $desc)
321
+	{
322
+		unset($conditions['page']);
323
+		$conditions = $this->constructConditions($conditions, $this->model);
324
+		$sort       = $desc ? 'desc' : 'asc';
325
+		$model      = $this->model->with($relations);
326
+
327
+		$model->whereHas('roles', function ($q) use ($roleName) {
328
+			$q->where('name', $roleName);
329
+		});
330 330
 
331 331
         
332
-        if (count($conditions['conditionValues'])) {
333
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
334
-        }
335
-
336
-        if ($perPage) {
337
-            return $model->orderBy($sortBy, $sort)->paginate($perPage);
338
-        }
339
-
340
-        return $model->orderBy($sortBy, $sort)->get();
341
-    }
342
-
343
-    /**
344
-     * Save the given data to the logged in user.
345
-     *
346
-     * @param  array $data
347
-     * @return void
348
-     */
349
-    public function saveProfile($data)
350
-    {
351
-        if (Arr::has($data, 'profile_picture')) {
352
-            $data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures');
353
-        }
332
+		if (count($conditions['conditionValues'])) {
333
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
334
+		}
335
+
336
+		if ($perPage) {
337
+			return $model->orderBy($sortBy, $sort)->paginate($perPage);
338
+		}
339
+
340
+		return $model->orderBy($sortBy, $sort)->get();
341
+	}
342
+
343
+	/**
344
+	 * Save the given data to the logged in user.
345
+	 *
346
+	 * @param  array $data
347
+	 * @return void
348
+	 */
349
+	public function saveProfile($data)
350
+	{
351
+		if (Arr::has($data, 'profile_picture')) {
352
+			$data['profile_picture'] = \Media::uploadImageBas64($data['profile_picture'], 'admins/profile_pictures');
353
+		}
354 354
         
355
-        $data['id'] = \Auth::id();
356
-        return $this->save($data);
357
-    }
358
-
359
-    /**
360
-     * Ensure access token hasn't expired or revoked.
361
-     *
362
-     * @param  string $accessToken
363
-     * @return boolean
364
-     */
365
-    public function accessTokenExpiredOrRevoked($accessToken)
366
-    {
367
-        $accessTokenId = json_decode($accessToken, true)['id'];
368
-        $accessToken   = \DB::table('oauth_access_tokens')
369
-                ->where('id', $accessTokenId)
370
-                ->first();
355
+		$data['id'] = \Auth::id();
356
+		return $this->save($data);
357
+	}
358
+
359
+	/**
360
+	 * Ensure access token hasn't expired or revoked.
361
+	 *
362
+	 * @param  string $accessToken
363
+	 * @return boolean
364
+	 */
365
+	public function accessTokenExpiredOrRevoked($accessToken)
366
+	{
367
+		$accessTokenId = json_decode($accessToken, true)['id'];
368
+		$accessToken   = \DB::table('oauth_access_tokens')
369
+				->where('id', $accessTokenId)
370
+				->first();
371 371
         
372
-        if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) {
373
-            return true;
374
-        }
375
-
376
-        return false;
377
-    }
378
-
379
-    /**
380
-     * Revoke the given access token and all
381
-     * associated refresh tokens.
382
-     *
383
-     * @param  oject $accessToken
384
-     * @return void
385
-     */
386
-    public function revokeAccessToken($accessToken)
387
-    {
388
-        \DB::table('oauth_refresh_tokens')
389
-            ->where('access_token_id', $accessToken->id)
390
-            ->update([
391
-                'revoked' => true
392
-            ]);
393
-
394
-        $accessToken->revoke();
395
-    }
372
+		if (\Carbon\Carbon::parse($accessToken->expires_at)->isPast() || $accessToken->revoked) {
373
+			return true;
374
+		}
375
+
376
+		return false;
377
+	}
378
+
379
+	/**
380
+	 * Revoke the given access token and all
381
+	 * associated refresh tokens.
382
+	 *
383
+	 * @param  oject $accessToken
384
+	 * @return void
385
+	 */
386
+	public function revokeAccessToken($accessToken)
387
+	{
388
+		\DB::table('oauth_refresh_tokens')
389
+			->where('access_token_id', $accessToken->id)
390
+			->update([
391
+				'revoked' => true
392
+			]);
393
+
394
+		$accessToken->revoke();
395
+	}
396 396
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $permissions = [];
29 29
         $user        = $this->find(\Auth::id(), $relations);
30 30
         foreach ($user->roles()->get() as $role) {
31
-            $role->permissions->each(function ($permission) use (&$permissions) {
31
+            $role->permissions->each(function($permission) use (&$permissions) {
32 32
                 $permissions[$permission->model][$permission->id] = $permission->name;
33 33
             });
34 34
         }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         $user        = $user ?: $this->find(\Auth::id(), ['roles.permissions']);
52 52
         $permissions = [];
53 53
 
54
-        $user->roles->pluck('permissions')->each(function ($permission) use (&$permissions, $model) {
54
+        $user->roles->pluck('permissions')->each(function($permission) use (&$permissions, $model) {
55 55
             $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray());
56 56
         });
57 57
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function assignRoles($userId, $roleIds)
82 82
     {
83
-        \DB::transaction(function () use ($userId, $roleIds) {
83
+        \DB::transaction(function() use ($userId, $roleIds) {
84 84
             $user = $this->find($userId);
85 85
             $user->roles()->detach();
86 86
             $user->roles()->attach($roleIds);
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function login($credentials, $adminLogin = false)
101 101
     {
102
-        if (! $user = $this->first(['email' => $credentials['email']])) {
102
+        if ( ! $user = $this->first(['email' => $credentials['email']])) {
103 103
             \ErrorHandler::loginFailed();
104 104
         } elseif ($adminLogin && ! $user->roles->whereIn('name', ['Admin'])->count()) {
105 105
             \ErrorHandler::loginFailed();
106
-        } elseif (! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) {
106
+        } elseif ( ! $adminLogin && $user->roles->whereIn('name', ['Admin'])->count()) {
107 107
             \ErrorHandler::loginFailed();
108 108
         } elseif ($user->blocked) {
109 109
             \ErrorHandler::userIsBlocked();
110
-        } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
110
+        } elseif ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
111 111
             \ErrorHandler::emailNotConfirmed();
112 112
         }
113 113
 
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
         $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
128 128
         $user         = \Socialite::driver($type)->userFromToken($access_token);
129 129
 
130
-        if (! $user->email) {
130
+        if ( ! $user->email) {
131 131
             \ErrorHandler::noSocialEmail();
132 132
         }
133 133
 
134
-        if (! $this->model->where('email', $user->email)->first()) {
134
+        if ( ! $this->model->where('email', $user->email)->first()) {
135 135
             $this->register(['email' => $user->email, 'password' => ''], true);
136 136
         }
137 137
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         if ($skipConfirmEmail) {
154 154
             $user->confirmed = 1;
155 155
             $user->save();
156
-        } elseif (! config('skeleton.disable_confirm_email')) {
156
+        } elseif ( ! config('skeleton.disable_confirm_email')) {
157 157
             $this->sendConfirmationEmail($user->email);
158 158
         }
159 159
 
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function block($userId)
170 170
     {
171
-        if (! $user = $this->find($userId)) {
171
+        if ( ! $user = $this->find($userId)) {
172 172
             \ErrorHandler::notFound('user');
173 173
         }
174
-        if (! $this->hasRole(['Admin'])) {
174
+        if ( ! $this->hasRole(['Admin'])) {
175 175
             \ErrorHandler::noPermissions();
176 176
         } elseif (\Auth::id() == $userId) {
177 177
             \ErrorHandler::noPermissions();
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function unblock($userId)
195 195
     {
196
-        if (! $this->hasRole(['Admin'])) {
196
+        if ( ! $this->hasRole(['Admin'])) {
197 197
             \ErrorHandler::noPermissions();
198 198
         }
199 199
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public function sendReset($email)
214 214
     {
215
-        if (! $user = $this->model->where('email', $email)->first()) {
215
+        if ( ! $user = $this->model->where('email', $email)->first()) {
216 216
             \ErrorHandler::notFound('email');
217 217
         }
218 218
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function resetPassword($credentials)
230 230
     {
231
-        $response = \Password::reset($credentials, function ($user, $password) {
231
+        $response = \Password::reset($credentials, function($user, $password) {
232 232
             $user->password = $password;
233 233
             $user->save();
234 234
         });
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     public function changePassword($credentials)
264 264
     {
265 265
         $user = \Auth::user();
266
-        if (! \Hash::check($credentials['old_password'], $user->password)) {
266
+        if ( ! \Hash::check($credentials['old_password'], $user->password)) {
267 267
             \ErrorHandler::invalidOldPassword();
268 268
         }
269 269
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function confirmEmail($confirmationCode)
281 281
     {
282
-        if (! $user = $this->first(['confirmation_code' => $confirmationCode])) {
282
+        if ( ! $user = $this->first(['confirmation_code' => $confirmationCode])) {
283 283
             \ErrorHandler::invalidConfirmationCode();
284 284
         }
285 285
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         $sort       = $desc ? 'desc' : 'asc';
325 325
         $model      = $this->model->with($relations);
326 326
 
327
-        $model->whereHas('roles', function ($q) use ($roleName) {
327
+        $model->whereHas('roles', function($q) use ($roleName) {
328 328
             $q->where('name', $roleName);
329 329
         });
330 330
 
Please login to merge, or discard this patch.
src/Modules/Users/Routes/api.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use Illuminate\Http\Request;
4
-
5 3
 /*
6 4
 |--------------------------------------------------------------------------
7 5
 | API Routes
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,31 +15,31 @@
 block discarded – undo
15 15
 
16 16
 Route::group(['prefix' => 'users'], function () {
17 17
 
18
-    Route::get('/', 'UserController@index');
19
-    Route::get('/{id}', 'UserController@find');
20
-    Route::post('/', 'UserController@insert');
21
-    Route::put('/', 'UserController@update');
22
-    Route::delete('/{id}', 'UserController@delete');
23
-    Route::get('list/deleted', 'UserController@deleted');
24
-    Route::patch('restore/{id}', 'UserController@restore');
25
-    Route::get('block/{id}', 'UserController@block');
26
-    Route::get('unblock/{id}', 'UserController@unblock');
27
-    Route::post('assign/roles', 'UserController@assignRoles');
28
-    Route::post('role/{roleName}', 'UserController@role');
18
+	Route::get('/', 'UserController@index');
19
+	Route::get('/{id}', 'UserController@find');
20
+	Route::post('/', 'UserController@insert');
21
+	Route::put('/', 'UserController@update');
22
+	Route::delete('/{id}', 'UserController@delete');
23
+	Route::get('list/deleted', 'UserController@deleted');
24
+	Route::patch('restore/{id}', 'UserController@restore');
25
+	Route::get('block/{id}', 'UserController@block');
26
+	Route::get('unblock/{id}', 'UserController@unblock');
27
+	Route::post('assign/roles', 'UserController@assignRoles');
28
+	Route::post('role/{roleName}', 'UserController@role');
29 29
 
30
-    Route::group(['prefix' => 'account'], function () {
30
+	Route::group(['prefix' => 'account'], function () {
31 31
 
32
-        Route::get('my', 'UserController@account');
33
-        Route::get('logout', 'UserController@logout');
34
-        Route::post('refresh/token', 'UserController@refreshToken');
35
-        Route::post('save', 'UserController@saveProfile');
36
-        Route::post('register', 'UserController@register');
37
-        Route::post('login', 'UserController@login');
38
-        Route::post('login/social', 'UserController@loginSocial');
39
-        Route::post('send/reset', 'UserController@sendReset');
40
-        Route::post('reset/password', 'UserController@resetPassword');
41
-        Route::post('change/password', 'UserController@changePassword');
42
-        Route::post('confirm/email', 'UserController@confirmEmail');
43
-        Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation');
44
-    });
32
+		Route::get('my', 'UserController@account');
33
+		Route::get('logout', 'UserController@logout');
34
+		Route::post('refresh/token', 'UserController@refreshToken');
35
+		Route::post('save', 'UserController@saveProfile');
36
+		Route::post('register', 'UserController@register');
37
+		Route::post('login', 'UserController@login');
38
+		Route::post('login/social', 'UserController@loginSocial');
39
+		Route::post('send/reset', 'UserController@sendReset');
40
+		Route::post('reset/password', 'UserController@resetPassword');
41
+		Route::post('change/password', 'UserController@changePassword');
42
+		Route::post('confirm/email', 'UserController@confirmEmail');
43
+		Route::post('resend/email/confirmation', 'UserController@resendEmailConfirmation');
44
+	});
45 45
 });
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 |
14 14
 */
15 15
 
16
-Route::group(['prefix' => 'users'], function () {
16
+Route::group(['prefix' => 'users'], function() {
17 17
 
18 18
     Route::get('/', 'UserController@index');
19 19
     Route::get('/{id}', 'UserController@find');
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     Route::post('assign/roles', 'UserController@assignRoles');
28 28
     Route::post('role/{roleName}', 'UserController@role');
29 29
 
30
-    Route::group(['prefix' => 'account'], function () {
30
+    Route::group(['prefix' => 'account'], function() {
31 31
 
32 32
         Route::get('my', 'UserController@account');
33 33
         Route::get('logout', 'UserController@logout');
Please login to merge, or discard this patch.
files/auth.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Authentication Defaults
8 8
     |--------------------------------------------------------------------------
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
     |
14 14
     */
15 15
 
16
-    'defaults' => [
17
-        'guard' => 'web',
18
-        'passwords' => 'users',
19
-    ],
16
+	'defaults' => [
17
+		'guard' => 'web',
18
+		'passwords' => 'users',
19
+	],
20 20
 
21
-    /*
21
+	/*
22 22
     |--------------------------------------------------------------------------
23 23
     | Authentication Guards
24 24
     |--------------------------------------------------------------------------
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
     |
36 36
     */
37 37
 
38
-    'guards' => [
39
-        'web' => [
40
-            'driver' => 'session',
41
-            'provider' => 'users',
42
-        ],
38
+	'guards' => [
39
+		'web' => [
40
+			'driver' => 'session',
41
+			'provider' => 'users',
42
+		],
43 43
 
44
-        'api' => [
45
-            'driver' => 'passport',
46
-            'provider' => 'users',
47
-        ],
48
-    ],
44
+		'api' => [
45
+			'driver' => 'passport',
46
+			'provider' => 'users',
47
+		],
48
+	],
49 49
 
50
-    /*
50
+	/*
51 51
     |--------------------------------------------------------------------------
52 52
     | User Providers
53 53
     |--------------------------------------------------------------------------
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
     |
65 65
     */
66 66
 
67
-    'providers' => [
68
-        'users' => [
69
-            'driver' => 'eloquent',
70
-            'model' => App\Modules\Users\AclUser::class,
71
-        ],
67
+	'providers' => [
68
+		'users' => [
69
+			'driver' => 'eloquent',
70
+			'model' => App\Modules\Users\AclUser::class,
71
+		],
72 72
 
73
-        // 'users' => [
74
-        //     'driver' => 'database',
75
-        //     'table' => 'users',
76
-        // ],
77
-    ],
73
+		// 'users' => [
74
+		//     'driver' => 'database',
75
+		//     'table' => 'users',
76
+		// ],
77
+	],
78 78
 
79
-    /*
79
+	/*
80 80
     |--------------------------------------------------------------------------
81 81
     | Resetting Passwords
82 82
     |--------------------------------------------------------------------------
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     |
92 92
     */
93 93
 
94
-    'passwords' => [
95
-        'users' => [
96
-            'provider' => 'users',
97
-            'table' => 'password_resets',
98
-            'expire' => 60,
99
-        ],
100
-    ],
94
+	'passwords' => [
95
+		'users' => [
96
+			'provider' => 'users',
97
+			'table' => 'password_resets',
98
+			'expire' => 60,
99
+		],
100
+	],
101 101
 
102 102
 ];
Please login to merge, or discard this patch.
config/skeleton.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Disable Confirm Email
8 8
     |--------------------------------------------------------------------------
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
     |
12 12
     */
13 13
 
14
-    'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', false),
14
+	'disable_confirm_email' => env('DISABLE_CONFIRM_EMAIL', false),
15 15
 
16
-    /*
16
+	/*
17 17
     |--------------------------------------------------------------------------
18 18
     | Confirm Email URL
19 19
     |--------------------------------------------------------------------------
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     |
23 23
     */
24 24
    
25
-    'confrim_email_url' => env('CONFIRM_EMAIL_URL'),
25
+	'confrim_email_url' => env('CONFIRM_EMAIL_URL'),
26 26
 
27
-    /*
27
+	/*
28 28
     |--------------------------------------------------------------------------
29 29
     | Reset Password URL
30 30
     |--------------------------------------------------------------------------
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
     |
34 34
     */
35 35
    
36
-    'reset_password_url' => env('RESET_PASSWORD_URL'),
36
+	'reset_password_url' => env('RESET_PASSWORD_URL'),
37 37
 
38
-    /*
38
+	/*
39 39
     |--------------------------------------------------------------------------
40 40
     | Passport Client Id
41 41
     |--------------------------------------------------------------------------
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
     |
45 45
     */
46 46
    
47
-    'passport_client_id' => env('PASSWORD_CLIENT_ID'),
47
+	'passport_client_id' => env('PASSWORD_CLIENT_ID'),
48 48
 
49
-    /*
49
+	/*
50 50
     |--------------------------------------------------------------------------
51 51
     | Passport Client Secret
52 52
     |--------------------------------------------------------------------------
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
     |
56 56
     */
57 57
    
58
-    'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'),
58
+	'passport_client_secret' => env('PASSWORD_CLIENT_SECRET'),
59 59
 
60
-    /*
60
+	/*
61 61
     |--------------------------------------------------------------------------
62 62
     | Social Pass
63 63
     |--------------------------------------------------------------------------
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
     |
67 67
     */
68 68
 
69
-    'social_pass' => env('SOCIAL_PASS', false),
69
+	'social_pass' => env('SOCIAL_PASS', false),
70 70
 
71
-    /*
71
+	/*
72 72
     |--------------------------------------------------------------------------
73 73
     | Relations Between Models
74 74
     |--------------------------------------------------------------------------
@@ -77,88 +77,88 @@  discard block
 block discarded – undo
77 77
     |
78 78
     */
79 79
     
80
-    'relations' => [
81
-        'user' => [
82
-            'list'       => [],
83
-            'find'       => [],
84
-            'findby'     => [],
85
-            'paginate'   => [],
86
-            'paginateby' => [],
87
-            'first'      => [],
88
-            'search'     => [],
89
-            'account'    => [],
90
-            'group'      => [],
91
-            'deleted'    => [],
92
-        ],
93
-        'permission' => [
94
-            'list'       => [],
95
-            'find'       => [],
96
-            'findby'     => [],
97
-            'paginate'   => [],
98
-            'paginateby' => [],
99
-            'first'      => [],
100
-            'search'     => [],
101
-            'deleted'    => [],
102
-        ],
103
-        'group' => [
104
-            'list'       => [],
105
-            'find'       => [],
106
-            'findby'     => [],
107
-            'paginate'   => [],
108
-            'paginateby' => [],
109
-            'first'      => [],
110
-            'search'     => [],
111
-            'deleted'    => [],
112
-        ],
113
-        'oauthClient' => [
114
-            'list'       => [],
115
-            'find'       => [],
116
-            'findby'     => [],
117
-            'paginate'   => [],
118
-            'paginateby' => [],
119
-            'first'      => [],
120
-            'search'     => [],
121
-            'account'    => [],
122
-            'group'      => [],
123
-            'deleted'    => [],
124
-        ],
125
-        'notification' => [
126
-            'list'   => [],
127
-            'unread' => [],
128
-        ],
129
-        'pushNotificationDevice' => [
130
-            'list'       => [],
131
-            'find'       => [],
132
-            'findby'     => [],
133
-            'paginate'   => [],
134
-            'paginateby' => [],
135
-            'first'      => [],
136
-            'search'     => [],
137
-            'deleted'    => [],
138
-        ],
139
-        'report' => [
140
-            'list'       => [],
141
-            'find'       => [],
142
-            'findby'     => [],
143
-            'paginate'   => [],
144
-            'paginateby' => [],
145
-            'first'      => [],
146
-            'search'     => [],
147
-            'deleted'    => [],
148
-        ],
149
-        'setting' => [
150
-            'list'       => [],
151
-            'find'       => [],
152
-            'findby'     => [],
153
-            'paginate'   => [],
154
-            'paginateby' => [],
155
-            'first'      => [],
156
-            'search'     => [],
157
-            'deleted'    => [],
158
-        ]
159
-    ],
80
+	'relations' => [
81
+		'user' => [
82
+			'list'       => [],
83
+			'find'       => [],
84
+			'findby'     => [],
85
+			'paginate'   => [],
86
+			'paginateby' => [],
87
+			'first'      => [],
88
+			'search'     => [],
89
+			'account'    => [],
90
+			'group'      => [],
91
+			'deleted'    => [],
92
+		],
93
+		'permission' => [
94
+			'list'       => [],
95
+			'find'       => [],
96
+			'findby'     => [],
97
+			'paginate'   => [],
98
+			'paginateby' => [],
99
+			'first'      => [],
100
+			'search'     => [],
101
+			'deleted'    => [],
102
+		],
103
+		'group' => [
104
+			'list'       => [],
105
+			'find'       => [],
106
+			'findby'     => [],
107
+			'paginate'   => [],
108
+			'paginateby' => [],
109
+			'first'      => [],
110
+			'search'     => [],
111
+			'deleted'    => [],
112
+		],
113
+		'oauthClient' => [
114
+			'list'       => [],
115
+			'find'       => [],
116
+			'findby'     => [],
117
+			'paginate'   => [],
118
+			'paginateby' => [],
119
+			'first'      => [],
120
+			'search'     => [],
121
+			'account'    => [],
122
+			'group'      => [],
123
+			'deleted'    => [],
124
+		],
125
+		'notification' => [
126
+			'list'   => [],
127
+			'unread' => [],
128
+		],
129
+		'pushNotificationDevice' => [
130
+			'list'       => [],
131
+			'find'       => [],
132
+			'findby'     => [],
133
+			'paginate'   => [],
134
+			'paginateby' => [],
135
+			'first'      => [],
136
+			'search'     => [],
137
+			'deleted'    => [],
138
+		],
139
+		'report' => [
140
+			'list'       => [],
141
+			'find'       => [],
142
+			'findby'     => [],
143
+			'paginate'   => [],
144
+			'paginateby' => [],
145
+			'first'      => [],
146
+			'search'     => [],
147
+			'deleted'    => [],
148
+		],
149
+		'setting' => [
150
+			'list'       => [],
151
+			'find'       => [],
152
+			'findby'     => [],
153
+			'paginate'   => [],
154
+			'paginateby' => [],
155
+			'first'      => [],
156
+			'search'     => [],
157
+			'deleted'    => [],
158
+		]
159
+	],
160 160
 
161
-    /*
161
+	/*
162 162
     |--------------------------------------------------------------------------
163 163
     | Cache Configurations
164 164
     |--------------------------------------------------------------------------
@@ -167,46 +167,46 @@  discard block
 block discarded – undo
167 167
     |
168 168
     */
169 169
 
170
-    'cache_config' => [
171
-        'oauthClient' => [
172
-            'cache' => [
173
-                'all',
174
-                'find',
175
-                'findBy',
176
-                'paginate',
177
-                'paginateBy',
178
-                'first',
179
-                'search',
180
-                'deleted'
181
-            ],
182
-            'clear' => [
183
-                'update'           => ['oauthClients', 'users', 'groups'],
184
-                'save'             => ['oauthClients', 'users', 'groups'],
185
-                'delete'           => ['oauthClients', 'users', 'groups'],
186
-                'restore'          => ['oauthClients', 'users', 'groups'],
187
-                'revoke'           => ['oauthClients', 'users', 'groups'],
188
-                'ubRevoke'         => ['oauthClients', 'users', 'groups'],
189
-                'regenerateSecret' => ['oauthClients', 'users', 'groups'],
190
-            ],
191
-        ],
192
-        'setting' => [
193
-            'cache' => [
194
-                'all',
195
-                'find',
196
-                'findBy',
197
-                'paginate',
198
-                'paginateBy',
199
-                'first',
200
-                'search',
201
-                'deleted'
202
-            ],
203
-            'clear' => [
204
-                'update'   => ['settings'],
205
-                'save'     => ['settings'],
206
-                'delete'   => ['settings'],
207
-                'restore'  => ['settings'],
208
-                'saveMany' => ['settings'],
209
-            ]
210
-        ]
211
-    ]
170
+	'cache_config' => [
171
+		'oauthClient' => [
172
+			'cache' => [
173
+				'all',
174
+				'find',
175
+				'findBy',
176
+				'paginate',
177
+				'paginateBy',
178
+				'first',
179
+				'search',
180
+				'deleted'
181
+			],
182
+			'clear' => [
183
+				'update'           => ['oauthClients', 'users', 'groups'],
184
+				'save'             => ['oauthClients', 'users', 'groups'],
185
+				'delete'           => ['oauthClients', 'users', 'groups'],
186
+				'restore'          => ['oauthClients', 'users', 'groups'],
187
+				'revoke'           => ['oauthClients', 'users', 'groups'],
188
+				'ubRevoke'         => ['oauthClients', 'users', 'groups'],
189
+				'regenerateSecret' => ['oauthClients', 'users', 'groups'],
190
+			],
191
+		],
192
+		'setting' => [
193
+			'cache' => [
194
+				'all',
195
+				'find',
196
+				'findBy',
197
+				'paginate',
198
+				'paginateBy',
199
+				'first',
200
+				'search',
201
+				'deleted'
202
+			],
203
+			'clear' => [
204
+				'update'   => ['settings'],
205
+				'save'     => ['settings'],
206
+				'delete'   => ['settings'],
207
+				'restore'  => ['settings'],
208
+				'saveMany' => ['settings'],
209
+			]
210
+		]
211
+	]
212 212
 ];
Please login to merge, or discard this patch.
src/Modules/Users/ModelObservers/AclUserObserver.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -6,62 +6,62 @@
 block discarded – undo
6 6
 class AclUserObserver
7 7
 {
8 8
 
9
-    public function saving($model)
10
-    {
11
-        if ($model->isDirty('profile_picture')) {
12
-            \Media::deleteImage($model->getOriginal('profile_picture'));
13
-        }
14
-    }
9
+	public function saving($model)
10
+	{
11
+		if ($model->isDirty('profile_picture')) {
12
+			\Media::deleteImage($model->getOriginal('profile_picture'));
13
+		}
14
+	}
15 15
 
16
-    public function saved($model)
17
-    {
18
-        //
19
-    }
16
+	public function saved($model)
17
+	{
18
+		//
19
+	}
20 20
 
21
-    public function creating($model)
22
-    {
23
-        //
24
-    }
21
+	public function creating($model)
22
+	{
23
+		//
24
+	}
25 25
 
26
-    public function created($model)
27
-    {
28
-        //
29
-    }
26
+	public function created($model)
27
+	{
28
+		//
29
+	}
30 30
 
31
-    public function updating($model)
32
-    {
33
-        //
34
-    }
31
+	public function updating($model)
32
+	{
33
+		//
34
+	}
35 35
 
36
-    public function updated($model)
37
-    {
38
-        if ($model->isDirty('blocked') && $model->blocked) {
39
-            $model->tokens()->each(function ($token) {
36
+	public function updated($model)
37
+	{
38
+		if ($model->isDirty('blocked') && $model->blocked) {
39
+			$model->tokens()->each(function ($token) {
40 40
 
41
-                \Core::users()->revokeAccessToken($token);
42
-            });
43
-        }
44
-    }
41
+				\Core::users()->revokeAccessToken($token);
42
+			});
43
+		}
44
+	}
45 45
 
46
-    public function deleting($model)
47
-    {
48
-        if ($model->getOriginal('id') == \Auth::id()) {
49
-            \ErrorHandler::noPermissions();
50
-        }
51
-    }
46
+	public function deleting($model)
47
+	{
48
+		if ($model->getOriginal('id') == \Auth::id()) {
49
+			\ErrorHandler::noPermissions();
50
+		}
51
+	}
52 52
 
53
-    public function deleted($model)
54
-    {
55
-        //
56
-    }
53
+	public function deleted($model)
54
+	{
55
+		//
56
+	}
57 57
 
58
-    public function restoring($model)
59
-    {
60
-        //
61
-    }
58
+	public function restoring($model)
59
+	{
60
+		//
61
+	}
62 62
 
63
-    public function restored($model)
64
-    {
65
-        //
66
-    }
63
+	public function restored($model)
64
+	{
65
+		//
66
+	}
67 67
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
     public function updated($model)
37 37
     {
38 38
         if ($model->isDirty('blocked') && $model->blocked) {
39
-            $model->tokens()->each(function ($token) {
39
+            $model->tokens()->each(function($token) {
40 40
 
41 41
                 \Core::users()->revokeAccessToken($token);
42 42
             });
Please login to merge, or discard this patch.
src/Modules/Users/Providers/ModuleServiceProvider.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class ModuleServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Bootstrap the module services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'users');
17
-        $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'users');
9
+	/**
10
+	 * Bootstrap the module services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'users');
17
+		$this->loadViewsFrom(__DIR__.'/../Resources/Views', 'users');
18 18
 
19
-        $this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app'));
20
-        $this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app'));
21
-    }
19
+		$this->loadMigrationsFrom(module_path('users', 'Database/Migrations', 'app'));
20
+		$this->loadFactoriesFrom(module_path('users', 'Database/Factories', 'app'));
21
+	}
22 22
 
23
-    /**
24
-     * Register the module services.
25
-     *
26
-     * @return void
27
-     */
28
-    public function register()
29
-    {
30
-        $this->app->register(RouteServiceProvider::class);
31
-    }
23
+	/**
24
+	 * Register the module services.
25
+	 *
26
+	 * @return void
27
+	 */
28
+	public function register()
29
+	{
30
+		$this->app->register(RouteServiceProvider::class);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Users/Providers/RouteServiceProvider.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -7,73 +7,73 @@
 block discarded – undo
7 7
 
8 8
 class RouteServiceProvider extends ServiceProvider
9 9
 {
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\Users\Http\Controllers';
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\Users\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('users', 'Routes/web.php', 'app');
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('users', 'Routes/web.php', 'app');
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('users', 'Routes/api.php', 'app');
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('users', 'Routes/api.php', 'app');
77
+		});
78
+	}
79 79
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         Route::group([
55 55
             'middleware' => 'web',
56 56
             'namespace'  => $this->namespace,
57
-        ], function ($router) {
57
+        ], function($router) {
58 58
             require module_path('users', 'Routes/web.php', 'app');
59 59
         });
60 60
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             'middleware' => 'api',
73 73
             'namespace'  => $this->namespace,
74 74
             'prefix'     => 'api',
75
-        ], function ($router) {
75
+        ], function($router) {
76 76
             require module_path('users', 'Routes/api.php', 'app');
77 77
         });
78 78
     }
Please login to merge, or discard this patch.