Completed
Push — master ( fb73c0...e952da )
by Sherif
07:01
created
src/lang/ar/notifications.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * Here goes your notification messages.
7
-     */
5
+	/**
6
+	 * Here goes your notification messages.
7
+	 */
8 8
 
9 9
 ];
10 10
\ No newline at end of file
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 3 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -4,316 +4,316 @@
 block discarded – undo
4 4
 
5 5
 class UserRepository extends AbstractRepository
6 6
 {
7
-    /**
8
-     * Return the model full namespace.
9
-     * 
10
-     * @return string
11
-     */
12
-    protected function getModel()
13
-    {
14
-        return 'App\Modules\V1\Acl\AclUser';
15
-    }
16
-
17
-    /**
18
-     * Return the logged in user account.
19
-     *
20
-     * @param  array   $relations
21
-     * @return boolean
22
-     */
23
-    public function account($relations = [])
24
-    {
25
-        $permissions = [];
26
-        $user        = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
27
-        foreach ($user->groups()->get() as $group)
28
-        {
29
-            $group->permissions->each(function ($permission) use (&$permissions){
30
-                $permissions[$permission->model][$permission->id] = $permission->name;
31
-            });
32
-        }
33
-        $user->permissions = $permissions;
34
-
35
-       return $user;
36
-    }
37
-
38
-    /**
39
-     * Check if the logged in user or the given user 
40
-     * has the given permissions on the given model.
41
-     * 
42
-     * @param  string  $nameOfPermission
43
-     * @param  string  $model            
44
-     * @param  boolean $user
45
-     * @return boolean
46
-     */
47
-    public function can($nameOfPermission, $model, $user = false )
48
-    {      
49
-        $user        = $user ?: \JWTAuth::parseToken()->authenticate();
50
-        $permissions = [];
51
-
52
-        if ( ! $user = $this->find($user->id, ['groups.permissions'])) 
53
-        {
54
-            \ErrorHandler::tokenExpired();
55
-        }
56
-
57
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
58
-            $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
59
-        });
7
+	/**
8
+	 * Return the model full namespace.
9
+	 * 
10
+	 * @return string
11
+	 */
12
+	protected function getModel()
13
+	{
14
+		return 'App\Modules\V1\Acl\AclUser';
15
+	}
16
+
17
+	/**
18
+	 * Return the logged in user account.
19
+	 *
20
+	 * @param  array   $relations
21
+	 * @return boolean
22
+	 */
23
+	public function account($relations = [])
24
+	{
25
+		$permissions = [];
26
+		$user        = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
27
+		foreach ($user->groups()->get() as $group)
28
+		{
29
+			$group->permissions->each(function ($permission) use (&$permissions){
30
+				$permissions[$permission->model][$permission->id] = $permission->name;
31
+			});
32
+		}
33
+		$user->permissions = $permissions;
34
+
35
+	   return $user;
36
+	}
37
+
38
+	/**
39
+	 * Check if the logged in user or the given user 
40
+	 * has the given permissions on the given model.
41
+	 * 
42
+	 * @param  string  $nameOfPermission
43
+	 * @param  string  $model            
44
+	 * @param  boolean $user
45
+	 * @return boolean
46
+	 */
47
+	public function can($nameOfPermission, $model, $user = false )
48
+	{      
49
+		$user        = $user ?: \JWTAuth::parseToken()->authenticate();
50
+		$permissions = [];
51
+
52
+		if ( ! $user = $this->find($user->id, ['groups.permissions'])) 
53
+		{
54
+			\ErrorHandler::tokenExpired();
55
+		}
56
+
57
+		$user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
58
+			$permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
59
+		});
60 60
         
61
-        return in_array($nameOfPermission, $permissions);
62
-    }
63
-
64
-    /**
65
-     * Check if the logged in user has the given group.
66
-     * 
67
-     * @param  string  $groupName
68
-     * @return boolean
69
-     */
70
-    public function hasGroup($groupName)
71
-    {
72
-        $groups = $this->find(\JWTAuth::parseToken()->authenticate()->id)->groups;
73
-        return $groups->pluck('name')->search($groupName, true) === false ? false : true;
74
-    }
75
-
76
-    /**
77
-     * Assign the given group ids to the given user.
78
-     * 
79
-     * @param  integer $user_id    
80
-     * @param  array   $group_ids
81
-     * @return object
82
-     */
83
-    public function assignGroups($user_id, $group_ids)
84
-    {
85
-        \DB::transaction(function () use ($user_id, $group_ids) {
86
-            $user = $this->find($user_id);
87
-            $user->groups()->detach();
88
-            $user->groups()->attach($group_ids);
89
-        });
90
-
91
-        return $this->find($user_id);
92
-    }
93
-
94
-    /**
95
-     * Handle a login request to the application.
96
-     * 
97
-     * @param  array   $credentials    
98
-     * @param  boolean $adminLogin
99
-     * @return array
100
-     */
101
-    public function login($credentials, $adminLogin = false)
102
-    {
103
-        if ( ! $user = $this->first(['email' => $credentials['email']])) 
104
-        {
105
-            \ErrorHandler::loginFailed();
106
-        }
107
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
108
-        {
109
-            \ErrorHandler::loginFailed();
110
-        }
111
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
112
-        {
113
-            \ErrorHandler::loginFailed();
114
-        }
115
-        else if ($user->blocked)
116
-        {
117
-            \ErrorHandler::userIsBlocked();
118
-        }
119
-        else if ($token = \JWTAuth::attempt($credentials))
120
-        {
121
-            return ['token' => $token];
122
-        }
123
-        else
124
-        {
125
-            \ErrorHandler::loginFailed();
126
-        }
127
-    }
128
-
129
-    /**
130
-     * Handle a social login request of the none admin to the application.
131
-     * 
132
-     * @param  array   $credentials
133
-     * @return array
134
-     */
135
-    public function loginSocial($credentials)
136
-    {
137
-        $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];   
138
-        $user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
139
-
140
-        if ( ! $user->email)
141
-        {
142
-            \ErrorHandler::noSocialEmail();
143
-        }
144
-
145
-        if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
146
-        {
147
-            $data = ['email' => $user->email, 'password' => ''];
148
-            return $this->register($data);
149
-        }
150
-        else
151
-        {
152
-            if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
153
-            {
154
-                \ErrorHandler::userAlreadyRegistered();
155
-            }
156
-            return $this->login(['email' => $registeredUser->email, 'password' => ''], false);
157
-        }
158
-    }
61
+		return in_array($nameOfPermission, $permissions);
62
+	}
63
+
64
+	/**
65
+	 * Check if the logged in user has the given group.
66
+	 * 
67
+	 * @param  string  $groupName
68
+	 * @return boolean
69
+	 */
70
+	public function hasGroup($groupName)
71
+	{
72
+		$groups = $this->find(\JWTAuth::parseToken()->authenticate()->id)->groups;
73
+		return $groups->pluck('name')->search($groupName, true) === false ? false : true;
74
+	}
75
+
76
+	/**
77
+	 * Assign the given group ids to the given user.
78
+	 * 
79
+	 * @param  integer $user_id    
80
+	 * @param  array   $group_ids
81
+	 * @return object
82
+	 */
83
+	public function assignGroups($user_id, $group_ids)
84
+	{
85
+		\DB::transaction(function () use ($user_id, $group_ids) {
86
+			$user = $this->find($user_id);
87
+			$user->groups()->detach();
88
+			$user->groups()->attach($group_ids);
89
+		});
90
+
91
+		return $this->find($user_id);
92
+	}
93
+
94
+	/**
95
+	 * Handle a login request to the application.
96
+	 * 
97
+	 * @param  array   $credentials    
98
+	 * @param  boolean $adminLogin
99
+	 * @return array
100
+	 */
101
+	public function login($credentials, $adminLogin = false)
102
+	{
103
+		if ( ! $user = $this->first(['email' => $credentials['email']])) 
104
+		{
105
+			\ErrorHandler::loginFailed();
106
+		}
107
+		else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
108
+		{
109
+			\ErrorHandler::loginFailed();
110
+		}
111
+		else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
112
+		{
113
+			\ErrorHandler::loginFailed();
114
+		}
115
+		else if ($user->blocked)
116
+		{
117
+			\ErrorHandler::userIsBlocked();
118
+		}
119
+		else if ($token = \JWTAuth::attempt($credentials))
120
+		{
121
+			return ['token' => $token];
122
+		}
123
+		else
124
+		{
125
+			\ErrorHandler::loginFailed();
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * Handle a social login request of the none admin to the application.
131
+	 * 
132
+	 * @param  array   $credentials
133
+	 * @return array
134
+	 */
135
+	public function loginSocial($credentials)
136
+	{
137
+		$access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];   
138
+		$user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
139
+
140
+		if ( ! $user->email)
141
+		{
142
+			\ErrorHandler::noSocialEmail();
143
+		}
144
+
145
+		if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
146
+		{
147
+			$data = ['email' => $user->email, 'password' => ''];
148
+			return $this->register($data);
149
+		}
150
+		else
151
+		{
152
+			if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
153
+			{
154
+				\ErrorHandler::userAlreadyRegistered();
155
+			}
156
+			return $this->login(['email' => $registeredUser->email, 'password' => ''], false);
157
+		}
158
+	}
159 159
     
160
-    /**
161
-     * Handle a registration request.
162
-     * 
163
-     * @param  array $credentials
164
-     * @return array
165
-     */
166
-    public function register($credentials)
167
-    {
168
-        return ['token' => \JWTAuth::fromUser($this->model->create($credentials))];
169
-    }
170
-
171
-    /**
172
-     * Logout the user.
173
-     * 
174
-     * @return boolean
175
-     */
176
-    public function logout()
177
-    {
178
-        return \JWTAuth::invalidate(\JWTAuth::getToken());
179
-    }
180
-
181
-    /**
182
-     * Block the user.
183
-     *
184
-     * @param  integer $user_id
185
-     * @return object
186
-     */
187
-    public function block($user_id)
188
-    {
189
-        if ( ! $user = $this->find($user_id)) 
190
-        {
191
-            \ErrorHandler::notFound('user');
192
-        }
193
-        if ( ! $this->hasGroup('Admin'))
194
-        {
195
-            \ErrorHandler::noPermissions();
196
-        }
197
-        else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
198
-        {
199
-            \ErrorHandler::noPermissions();
200
-        }
201
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
202
-        {
203
-            \ErrorHandler::noPermissions();
204
-        }
205
-
206
-        $user->blocked = 1;
207
-        $user->save();
160
+	/**
161
+	 * Handle a registration request.
162
+	 * 
163
+	 * @param  array $credentials
164
+	 * @return array
165
+	 */
166
+	public function register($credentials)
167
+	{
168
+		return ['token' => \JWTAuth::fromUser($this->model->create($credentials))];
169
+	}
170
+
171
+	/**
172
+	 * Logout the user.
173
+	 * 
174
+	 * @return boolean
175
+	 */
176
+	public function logout()
177
+	{
178
+		return \JWTAuth::invalidate(\JWTAuth::getToken());
179
+	}
180
+
181
+	/**
182
+	 * Block the user.
183
+	 *
184
+	 * @param  integer $user_id
185
+	 * @return object
186
+	 */
187
+	public function block($user_id)
188
+	{
189
+		if ( ! $user = $this->find($user_id)) 
190
+		{
191
+			\ErrorHandler::notFound('user');
192
+		}
193
+		if ( ! $this->hasGroup('Admin'))
194
+		{
195
+			\ErrorHandler::noPermissions();
196
+		}
197
+		else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
198
+		{
199
+			\ErrorHandler::noPermissions();
200
+		}
201
+		else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
202
+		{
203
+			\ErrorHandler::noPermissions();
204
+		}
205
+
206
+		$user->blocked = 1;
207
+		$user->save();
208 208
         
209
-        return $user;
210
-    }
211
-
212
-    /**
213
-     * Unblock the user.
214
-     *
215
-     * @param  integer $user_id
216
-     * @return object
217
-     */
218
-    public function unblock($user_id)
219
-    {
220
-        if ( ! $this->hasGroup('Admin'))
221
-        {
222
-            \ErrorHandler::noPermissions();
223
-        }
224
-
225
-        $user          = $this->find($user_id);
226
-        $user->blocked = 0;
227
-        $user->save();
228
-
229
-        return $user;
230
-    }
231
-
232
-    /**
233
-     * Send a reset link to the given user.
234
-     *
235
-     * @param  string  $url
236
-     * @param  string  $email
237
-     * @return void
238
-     */
239
-    public function sendReset($email, $url)
240
-    {
241
-        view()->composer('auth.emails.password', function($view) use ($url) {
242
-            $view->with(['url' => $url]);
243
-        });
244
-
245
-        $response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) {
246
-            $message->subject('Your Password Reset Link');
247
-        });
248
-
249
-        switch ($response) 
250
-        {
251
-            case \Password::INVALID_USER:
252
-                \ErrorHandler::notFound('email');
253
-        }
254
-    }
255
-
256
-    /**
257
-     * Reset the given user's password.
258
-     *
259
-     * @param  array  $credentials
260
-     * @return array
261
-     */
262
-    public function resetPassword($credentials)
263
-    {
264
-        $token    = false;
265
-        $response = \Password::reset($credentials, function ($user, $password) use (&$token) {
266
-            $user->password = bcrypt($password);
267
-            $user->save();
268
-
269
-            $token = \JWTAuth::fromUser($user);
270
-        });
271
-
272
-        switch ($response) {
273
-            case \Password::PASSWORD_RESET:
274
-                return ['token' => $token];
209
+		return $user;
210
+	}
211
+
212
+	/**
213
+	 * Unblock the user.
214
+	 *
215
+	 * @param  integer $user_id
216
+	 * @return object
217
+	 */
218
+	public function unblock($user_id)
219
+	{
220
+		if ( ! $this->hasGroup('Admin'))
221
+		{
222
+			\ErrorHandler::noPermissions();
223
+		}
224
+
225
+		$user          = $this->find($user_id);
226
+		$user->blocked = 0;
227
+		$user->save();
228
+
229
+		return $user;
230
+	}
231
+
232
+	/**
233
+	 * Send a reset link to the given user.
234
+	 *
235
+	 * @param  string  $url
236
+	 * @param  string  $email
237
+	 * @return void
238
+	 */
239
+	public function sendReset($email, $url)
240
+	{
241
+		view()->composer('auth.emails.password', function($view) use ($url) {
242
+			$view->with(['url' => $url]);
243
+		});
244
+
245
+		$response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) {
246
+			$message->subject('Your Password Reset Link');
247
+		});
248
+
249
+		switch ($response) 
250
+		{
251
+			case \Password::INVALID_USER:
252
+				\ErrorHandler::notFound('email');
253
+		}
254
+	}
255
+
256
+	/**
257
+	 * Reset the given user's password.
258
+	 *
259
+	 * @param  array  $credentials
260
+	 * @return array
261
+	 */
262
+	public function resetPassword($credentials)
263
+	{
264
+		$token    = false;
265
+		$response = \Password::reset($credentials, function ($user, $password) use (&$token) {
266
+			$user->password = bcrypt($password);
267
+			$user->save();
268
+
269
+			$token = \JWTAuth::fromUser($user);
270
+		});
271
+
272
+		switch ($response) {
273
+			case \Password::PASSWORD_RESET:
274
+				return ['token' => $token];
275 275
                 
276
-            case \Password::INVALID_TOKEN:
277
-                \ErrorHandler::invalidResetToken('token');
278
-
279
-            case \Password::INVALID_PASSWORD:
280
-                \ErrorHandler::invalidResetPassword('email');
281
-
282
-            case \Password::INVALID_USER:
283
-                \ErrorHandler::notFound('user');
284
-
285
-            default:
286
-                \ErrorHandler::generalError();
287
-        }
288
-    }
289
-
290
-    /**
291
-     * Change the logged in user password.
292
-     *
293
-     * @param  array  $credentials
294
-     * @return void
295
-     */
296
-    public function changePassword($credentials)
297
-    {
298
-        $user = $this->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
299
-        if ( ! \Hash::check($credentials['old_password'], $user->password)) 
300
-        {
301
-            \ErrorHandler::invalidOldPassword();
302
-        }
303
-
304
-        $user->password = $credentials['password'];
305
-        $user->save();
306
-    }
307
-
308
-    /**
309
-     * Refresh the expired login token.
310
-     *
311
-     * @return array
312
-     */
313
-    public function refreshtoken()
314
-    {
315
-        $token = \JWTAuth::parseToken()->refresh();
316
-
317
-        return ['token' => $token];
318
-    }
276
+			case \Password::INVALID_TOKEN:
277
+				\ErrorHandler::invalidResetToken('token');
278
+
279
+			case \Password::INVALID_PASSWORD:
280
+				\ErrorHandler::invalidResetPassword('email');
281
+
282
+			case \Password::INVALID_USER:
283
+				\ErrorHandler::notFound('user');
284
+
285
+			default:
286
+				\ErrorHandler::generalError();
287
+		}
288
+	}
289
+
290
+	/**
291
+	 * Change the logged in user password.
292
+	 *
293
+	 * @param  array  $credentials
294
+	 * @return void
295
+	 */
296
+	public function changePassword($credentials)
297
+	{
298
+		$user = $this->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
299
+		if ( ! \Hash::check($credentials['old_password'], $user->password)) 
300
+		{
301
+			\ErrorHandler::invalidOldPassword();
302
+		}
303
+
304
+		$user->password = $credentials['password'];
305
+		$user->save();
306
+	}
307
+
308
+	/**
309
+	 * Refresh the expired login token.
310
+	 *
311
+	 * @return array
312
+	 */
313
+	public function refreshtoken()
314
+	{
315
+		$token = \JWTAuth::parseToken()->refresh();
316
+
317
+		return ['token' => $token];
318
+	}
319 319
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $user        = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
27 27
         foreach ($user->groups()->get() as $group)
28 28
         {
29
-            $group->permissions->each(function ($permission) use (&$permissions){
29
+            $group->permissions->each(function($permission) use (&$permissions){
30 30
                 $permissions[$permission->model][$permission->id] = $permission->name;
31 31
             });
32 32
         }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @param  boolean $user
45 45
      * @return boolean
46 46
      */
47
-    public function can($nameOfPermission, $model, $user = false )
47
+    public function can($nameOfPermission, $model, $user = false)
48 48
     {      
49 49
         $user        = $user ?: \JWTAuth::parseToken()->authenticate();
50 50
         $permissions = [];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             \ErrorHandler::tokenExpired();
55 55
         }
56 56
 
57
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
57
+        $user->groups->pluck('permissions')->each(function($permission) use (&$permissions, $model){
58 58
             $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
59 59
         });
60 60
         
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function assignGroups($user_id, $group_ids)
84 84
     {
85
-        \DB::transaction(function () use ($user_id, $group_ids) {
85
+        \DB::transaction(function() use ($user_id, $group_ids) {
86 86
             $user = $this->find($user_id);
87 87
             $user->groups()->detach();
88 88
             $user->groups()->attach($group_ids);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
             $view->with(['url' => $url]);
243 243
         });
244 244
 
245
-        $response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) {
245
+        $response = \Password::sendResetLink($email, function(\Illuminate\Mail\Message $message) {
246 246
             $message->subject('Your Password Reset Link');
247 247
         });
248 248
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     public function resetPassword($credentials)
263 263
     {
264 264
         $token    = false;
265
-        $response = \Password::reset($credentials, function ($user, $password) use (&$token) {
265
+        $response = \Password::reset($credentials, function($user, $password) use (&$token) {
266 266
             $user->password = bcrypt($password);
267 267
             $user->save();
268 268
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -103,24 +103,19 @@  discard block
 block discarded – undo
103 103
         if ( ! $user = $this->first(['email' => $credentials['email']])) 
104 104
         {
105 105
             \ErrorHandler::loginFailed();
106
-        }
107
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
106
+        } else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
108 107
         {
109 108
             \ErrorHandler::loginFailed();
110
-        }
111
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
109
+        } else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
112 110
         {
113 111
             \ErrorHandler::loginFailed();
114
-        }
115
-        else if ($user->blocked)
112
+        } else if ($user->blocked)
116 113
         {
117 114
             \ErrorHandler::userIsBlocked();
118
-        }
119
-        else if ($token = \JWTAuth::attempt($credentials))
115
+        } else if ($token = \JWTAuth::attempt($credentials))
120 116
         {
121 117
             return ['token' => $token];
122
-        }
123
-        else
118
+        } else
124 119
         {
125 120
             \ErrorHandler::loginFailed();
126 121
         }
@@ -146,8 +141,7 @@  discard block
 block discarded – undo
146 141
         {
147 142
             $data = ['email' => $user->email, 'password' => ''];
148 143
             return $this->register($data);
149
-        }
150
-        else
144
+        } else
151 145
         {
152 146
             if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
153 147
             {
@@ -193,12 +187,10 @@  discard block
 block discarded – undo
193 187
         if ( ! $this->hasGroup('Admin'))
194 188
         {
195 189
             \ErrorHandler::noPermissions();
196
-        }
197
-        else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
190
+        } else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
198 191
         {
199 192
             \ErrorHandler::noPermissions();
200
-        }
201
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
193
+        } else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
202 194
         {
203 195
             \ErrorHandler::noPermissions();
204 196
         }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Migrations/2015_12_20_124153_users.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	 */
13 13
 	public function up()
14 14
 	{
15
-		Schema::create('users', function (Blueprint $table) {
15
+		Schema::create('users', function(Blueprint $table) {
16 16
             $table->increments('id');
17 17
             $table->string('name', 100)->default('');
18 18
             $table->string('email')->unique();
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('users', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name', 100)->default('');
18
-            $table->string('email')->unique();
19
-            $table->string('password', 60);
20
-            $table->boolean('blocked')->default(0);
16
+			$table->increments('id');
17
+			$table->string('name', 100)->default('');
18
+			$table->string('email')->unique();
19
+			$table->string('password', 60);
20
+			$table->boolean('blocked')->default(0);
21 21
 			$table->date('last_change_password')->default(null);
22
-            $table->softDeletes();
23
-            $table->rememberToken();
24
-            $table->timestamps();
25
-        });
22
+			$table->softDeletes();
23
+			$table->rememberToken();
24
+			$table->timestamps();
25
+		});
26 26
 	}
27 27
 
28 28
 	/**
Please login to merge, or discard this patch.
src/Modules/V1/Acl/ModelObservers/AclUserObserver.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -5,57 +5,57 @@
 block discarded – undo
5 5
  */
6 6
 class AclUserObserver {
7 7
 
8
-    public function saving($model)
9
-    {
10
-        //
11
-    }
12
-
13
-    public function saved($model)
14
-    {
15
-        //
16
-    }
17
-
18
-    public function creating($model)
19
-    {
20
-        //
21
-    }
22
-
23
-    public function created($model)
24
-    {
25
-        //
26
-    }
27
-
28
-    public function updating($model)
29
-    {
30
-        if ($model->password) 
31
-        {
32
-            $model->last_change_password = \Carbon\Carbon::now()->toDateTimeString();
33
-        }
34
-    }
35
-
36
-    public function updated($model)
37
-    {
38
-        //
39
-    }
40
-
41
-    /**
42
-     * Soft delete user logs.
43
-     * 
44
-     * @param  object $model the delted model.
45
-     * @return void
46
-     */
47
-    public function deleting($model)
48
-    {
49
-        if ($model->getOriginal('id') == \JWTAuth::parseToken()->authenticate()->id) 
50
-        {
51
-            \ErrorHandler::noPermissions();
52
-        }
53
-        $model->logs()->delete();
54
-    }
55
-
56
-    public function deleted($model)
57
-    {
58
-        //
59
-    }
8
+	public function saving($model)
9
+	{
10
+		//
11
+	}
12
+
13
+	public function saved($model)
14
+	{
15
+		//
16
+	}
17
+
18
+	public function creating($model)
19
+	{
20
+		//
21
+	}
22
+
23
+	public function created($model)
24
+	{
25
+		//
26
+	}
27
+
28
+	public function updating($model)
29
+	{
30
+		if ($model->password) 
31
+		{
32
+			$model->last_change_password = \Carbon\Carbon::now()->toDateTimeString();
33
+		}
34
+	}
35
+
36
+	public function updated($model)
37
+	{
38
+		//
39
+	}
40
+
41
+	/**
42
+	 * Soft delete user logs.
43
+	 * 
44
+	 * @param  object $model the delted model.
45
+	 * @return void
46
+	 */
47
+	public function deleting($model)
48
+	{
49
+		if ($model->getOriginal('id') == \JWTAuth::parseToken()->authenticate()->id) 
50
+		{
51
+			\ErrorHandler::noPermissions();
52
+		}
53
+		$model->logs()->delete();
54
+	}
55
+
56
+	public function deleted($model)
57
+	{
58
+		//
59
+	}
60 60
 
61 61
 }
62 62
\ No newline at end of file
Please login to merge, or discard this patch.
V1/Reporting/Database/Migrations/2016_01_24_123631_initialize_reports.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -13,65 +13,65 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		/**
16
-         * Insert the permissions related to this module.
17
-         */
18
-        DB::table('permissions')->insert(
19
-        	[
20
-        		/**
21
-        		 * Reporting model permissions.
22
-        		 */
23
-	        	[
24
-	        	'name'       => 'find',
25
-	        	'model'      => 'reports',
26
-	        	'created_at' => \DB::raw('NOW()'),
27
-	        	'updated_at' => \DB::raw('NOW()')
28
-	        	],
29
-	        	[
30
-	        	'name'       => 'search',
31
-	        	'model'      => 'reports',
32
-	        	'created_at' => \DB::raw('NOW()'),
33
-	        	'updated_at' => \DB::raw('NOW()')
34
-	        	],
35
-	        	[
36
-	        	'name'       => 'list',
37
-	        	'model'      => 'reports',
38
-	        	'created_at' => \DB::raw('NOW()'),
39
-	        	'updated_at' => \DB::raw('NOW()')
40
-	        	],
41
-	        	[
42
-	        	'name'       => 'findby',
43
-	        	'model'      => 'reports',
44
-	        	'created_at' => \DB::raw('NOW()'),
45
-	        	'updated_at' => \DB::raw('NOW()')
46
-	        	],
47
-	        	[
48
-	        	'name'       => 'first',
49
-	        	'model'      => 'reports',
50
-	        	'created_at' => \DB::raw('NOW()'),
51
-	        	'updated_at' => \DB::raw('NOW()')
52
-	        	],
53
-	        	[
54
-	        	'name'       => 'paginate',
55
-	        	'model'      => 'reports',
56
-	        	'created_at' => \DB::raw('NOW()'),
57
-	        	'updated_at' => \DB::raw('NOW()')
58
-	        	],
59
-	        	[
60
-	        	'name'       => 'paginateby',
61
-	        	'model'      => 'reports',
62
-	        	'created_at' => \DB::raw('NOW()'),
63
-	        	'updated_at' => \DB::raw('NOW()')
64
-	        	],
65
-	        	[
66
-	        	'name'       => 'admin_count',
67
-	        	'model'      => 'reports',
68
-	        	'created_at' => \DB::raw('NOW()'),
69
-	        	'updated_at' => \DB::raw('NOW()')
70
-	        	]
71
-        	]
72
-        );
16
+		 * Insert the permissions related to this module.
17
+		 */
18
+		DB::table('permissions')->insert(
19
+			[
20
+				/**
21
+				 * Reporting model permissions.
22
+				 */
23
+				[
24
+				'name'       => 'find',
25
+				'model'      => 'reports',
26
+				'created_at' => \DB::raw('NOW()'),
27
+				'updated_at' => \DB::raw('NOW()')
28
+				],
29
+				[
30
+				'name'       => 'search',
31
+				'model'      => 'reports',
32
+				'created_at' => \DB::raw('NOW()'),
33
+				'updated_at' => \DB::raw('NOW()')
34
+				],
35
+				[
36
+				'name'       => 'list',
37
+				'model'      => 'reports',
38
+				'created_at' => \DB::raw('NOW()'),
39
+				'updated_at' => \DB::raw('NOW()')
40
+				],
41
+				[
42
+				'name'       => 'findby',
43
+				'model'      => 'reports',
44
+				'created_at' => \DB::raw('NOW()'),
45
+				'updated_at' => \DB::raw('NOW()')
46
+				],
47
+				[
48
+				'name'       => 'first',
49
+				'model'      => 'reports',
50
+				'created_at' => \DB::raw('NOW()'),
51
+				'updated_at' => \DB::raw('NOW()')
52
+				],
53
+				[
54
+				'name'       => 'paginate',
55
+				'model'      => 'reports',
56
+				'created_at' => \DB::raw('NOW()'),
57
+				'updated_at' => \DB::raw('NOW()')
58
+				],
59
+				[
60
+				'name'       => 'paginateby',
61
+				'model'      => 'reports',
62
+				'created_at' => \DB::raw('NOW()'),
63
+				'updated_at' => \DB::raw('NOW()')
64
+				],
65
+				[
66
+				'name'       => 'admin_count',
67
+				'model'      => 'reports',
68
+				'created_at' => \DB::raw('NOW()'),
69
+				'updated_at' => \DB::raw('NOW()')
70
+				]
71
+			]
72
+		);
73 73
 
74
-        /**
74
+		/**
75 75
 		 * Assign the permissions to the admin group.
76 76
 		 */
77 77
 		$permissionIds = DB::table('permissions')->whereIn('model', ['reports'])->select('id')->lists('id');
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
 	 */
102 102
 	public function down()
103 103
 	{
104
-		$permissions  = DB::table('permissions')->whereIn('model', ['reports']);
104
+		$permissions = DB::table('permissions')->whereIn('model', ['reports']);
105 105
 		DB::table('groups_permissions')->whereIn('permission_id', $permissions->lists('id'))->delete();
106 106
 		$permissions->delete();
107 107
 	}
Please login to merge, or discard this patch.