Completed
Push — master ( f30158...bfbb50 )
by Sherif
02:18
created
src/Modules/Users/Services/UserService.php 1 patch
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -12,378 +12,378 @@
 block discarded – undo
12 12
 
13 13
 class UserService extends BaseService
14 14
 {
15
-    /**
16
-     * @var PermissionService
17
-     */
18
-    protected $permissionService;
19
-
20
-    /**
21
-     * @var LoginProxy
22
-     */
23
-    protected $loginProxy;
24
-
25
-    /**
26
-     * @var NotificationService
27
-     */
28
-    protected $notificationService;
29
-
30
-    /**
31
-     * @var OauthClientService
32
-     */
33
-    protected $oauthClientService;
34
-
35
-    /**
36
-     * Init new object.
37
-     *
38
-     * @param   UserRepository       $repo
39
-     * @param   PermissionService    $permissionService
40
-     * @param   LoginProxy           $loginProxy
41
-     * @param   NotificationService  $notificationService
42
-     * @param   OauthClientService   $oauthClientService
43
-     * @return  void
44
-     */
45
-    public function __construct(
46
-        UserRepository $repo,
47
-        PermissionService $permissionService,
48
-        LoginProxy $loginProxy,
49
-        NotificationService $notificationService,
50
-        OauthClientService $oauthClientService
51
-    ) {
52
-        $this->permissionService   = $permissionService;
53
-        $this->loginProxy          = $loginProxy;
54
-        $this->notificationService = $notificationService;
55
-        $this->oauthClientService  = $oauthClientService;
56
-        parent::__construct($repo);
57
-    }
58
-
59
-    /**
60
-     * Return the logged in user account.
61
-     *
62
-     * @param  array   $relations
63
-     * @return boolean
64
-     */
65
-    public function account($relations = ['roles.permissions'])
66
-    {
67
-        $permissions = [];
68
-        $user        = $this->repo->find(\Auth::id(), $relations);
69
-        foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
71
-                $permissions[$permission->repo][$permission->id] = $permission->name;
72
-            });
73
-        }
74
-        $user->permissions = $permissions;
75
-
76
-        return $user;
77
-    }
78
-
79
-    /**
80
-     * Check if the logged in user or the given user
81
-     * has the given permissions on the given model.
82
-     *
83
-     * @param  string $permissionName
84
-     * @param  string $model
85
-     * @param  mixed  $userId
86
-     * @return boolean
87
-     */
88
-    public function can($permissionName, $model, $userId = false)
89
-    {
90
-        $permission = $this->permissionService->first([
91
-            'and' => [
92
-                'model' => $model,
93
-                'name'  => $permissionName,
94
-                'roles' => [
95
-                    'op' => 'has',
96
-                    'val' => [
97
-                        'users' => [
98
-                            'op' => 'has',
99
-                            'val' => [
100
-                                'users.id' => $userId ?: \Auth::id()
101
-                            ]
102
-                        ]
103
-                    ]
104
-                ]
105
-            ]
106
-        ]);
107
-
108
-        return $permission ? true : false;
109
-    }
110
-
111
-    /**
112
-     * Check if the logged in or the given user has the given role.
113
-     *
114
-     * @param  string[] $roles
115
-     * @param  mixed    $user
116
-     * @return boolean
117
-     */
118
-    public function hasRoles($roles, $user = false)
119
-    {
120
-        return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
-    }
122
-
123
-    /**
124
-     * Assign the given role ids to the given user.
125
-     *
126
-     * @param  integer $userId
127
-     * @param  array   $roleIds
128
-     * @return object
129
-     */
130
-    public function assignRoles($userId, $roleIds)
131
-    {
132
-        $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
134
-            $user = $this->repo->find($userId);
135
-            $this->repo->detachPermissions($userId);
136
-            $this->repo->attachPermissions($userId, $roleIds);
137
-        });
138
-
139
-        return $user;
140
-    }
141
-
142
-    /**
143
-     * Handle a login request to the application.
144
-     *
145
-     * @param  string  $email
146
-     * @param  string  $password
147
-     * @param  boolean $adminLogin
148
-     * @return object
149
-     */
150
-    public function login($email, $password, $adminLogin = false)
151
-    {
152
-        if (! $user = $this->repo->first(['email' => $email])) {
153
-            \Errors::loginFailed();
154
-        } elseif ($adminLogin && ! $this->hasRoles(['Admin'], $user)) {
155
-            \Errors::loginFailed();
156
-        } elseif (! $adminLogin && $this->hasRoles(['Admin'], $user)) {
157
-            \Errors::loginFailed();
158
-        } elseif ($user->blocked) {
159
-            \Errors::userIsBlocked();
160
-        } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
161
-            \Errors::emailNotConfirmed();
162
-        }
163
-
164
-        return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
165
-    }
166
-
167
-    /**
168
-     * Handle a social login request of the none admin to the application.
169
-     *
170
-     * @param  string $authCode
171
-     * @param  string $accessToken
172
-     * @param  string $type
173
-     * @return array
174
-     */
175
-    public function loginSocial($authCode, $accessToken, $type)
176
-    {
177
-        $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
178
-        $user         = \Socialite::driver($type)->userFromToken($access_token);
179
-
180
-        if (! $user->email) {
181
-            \Errors::noSocialEmail();
182
-        }
183
-
184
-        if (! $this->repo->first(['email' => $user->email])) {
185
-            $this->register($user->email, '', true);
186
-        }
187
-
188
-        return $this->loginProxy->login($user->email, config('skeleton.social_pass'));
189
-    }
15
+	/**
16
+	 * @var PermissionService
17
+	 */
18
+	protected $permissionService;
19
+
20
+	/**
21
+	 * @var LoginProxy
22
+	 */
23
+	protected $loginProxy;
24
+
25
+	/**
26
+	 * @var NotificationService
27
+	 */
28
+	protected $notificationService;
29
+
30
+	/**
31
+	 * @var OauthClientService
32
+	 */
33
+	protected $oauthClientService;
34
+
35
+	/**
36
+	 * Init new object.
37
+	 *
38
+	 * @param   UserRepository       $repo
39
+	 * @param   PermissionService    $permissionService
40
+	 * @param   LoginProxy           $loginProxy
41
+	 * @param   NotificationService  $notificationService
42
+	 * @param   OauthClientService   $oauthClientService
43
+	 * @return  void
44
+	 */
45
+	public function __construct(
46
+		UserRepository $repo,
47
+		PermissionService $permissionService,
48
+		LoginProxy $loginProxy,
49
+		NotificationService $notificationService,
50
+		OauthClientService $oauthClientService
51
+	) {
52
+		$this->permissionService   = $permissionService;
53
+		$this->loginProxy          = $loginProxy;
54
+		$this->notificationService = $notificationService;
55
+		$this->oauthClientService  = $oauthClientService;
56
+		parent::__construct($repo);
57
+	}
58
+
59
+	/**
60
+	 * Return the logged in user account.
61
+	 *
62
+	 * @param  array   $relations
63
+	 * @return boolean
64
+	 */
65
+	public function account($relations = ['roles.permissions'])
66
+	{
67
+		$permissions = [];
68
+		$user        = $this->repo->find(\Auth::id(), $relations);
69
+		foreach ($user->roles as $role) {
70
+			$role->permissions->each(function ($permission) use (&$permissions) {
71
+				$permissions[$permission->repo][$permission->id] = $permission->name;
72
+			});
73
+		}
74
+		$user->permissions = $permissions;
75
+
76
+		return $user;
77
+	}
78
+
79
+	/**
80
+	 * Check if the logged in user or the given user
81
+	 * has the given permissions on the given model.
82
+	 *
83
+	 * @param  string $permissionName
84
+	 * @param  string $model
85
+	 * @param  mixed  $userId
86
+	 * @return boolean
87
+	 */
88
+	public function can($permissionName, $model, $userId = false)
89
+	{
90
+		$permission = $this->permissionService->first([
91
+			'and' => [
92
+				'model' => $model,
93
+				'name'  => $permissionName,
94
+				'roles' => [
95
+					'op' => 'has',
96
+					'val' => [
97
+						'users' => [
98
+							'op' => 'has',
99
+							'val' => [
100
+								'users.id' => $userId ?: \Auth::id()
101
+							]
102
+						]
103
+					]
104
+				]
105
+			]
106
+		]);
107
+
108
+		return $permission ? true : false;
109
+	}
110
+
111
+	/**
112
+	 * Check if the logged in or the given user has the given role.
113
+	 *
114
+	 * @param  string[] $roles
115
+	 * @param  mixed    $user
116
+	 * @return boolean
117
+	 */
118
+	public function hasRoles($roles, $user = false)
119
+	{
120
+		return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
+	}
122
+
123
+	/**
124
+	 * Assign the given role ids to the given user.
125
+	 *
126
+	 * @param  integer $userId
127
+	 * @param  array   $roleIds
128
+	 * @return object
129
+	 */
130
+	public function assignRoles($userId, $roleIds)
131
+	{
132
+		$user = false;
133
+		\DB::transaction(function () use ($userId, $roleIds, &$user) {
134
+			$user = $this->repo->find($userId);
135
+			$this->repo->detachPermissions($userId);
136
+			$this->repo->attachPermissions($userId, $roleIds);
137
+		});
138
+
139
+		return $user;
140
+	}
141
+
142
+	/**
143
+	 * Handle a login request to the application.
144
+	 *
145
+	 * @param  string  $email
146
+	 * @param  string  $password
147
+	 * @param  boolean $adminLogin
148
+	 * @return object
149
+	 */
150
+	public function login($email, $password, $adminLogin = false)
151
+	{
152
+		if (! $user = $this->repo->first(['email' => $email])) {
153
+			\Errors::loginFailed();
154
+		} elseif ($adminLogin && ! $this->hasRoles(['Admin'], $user)) {
155
+			\Errors::loginFailed();
156
+		} elseif (! $adminLogin && $this->hasRoles(['Admin'], $user)) {
157
+			\Errors::loginFailed();
158
+		} elseif ($user->blocked) {
159
+			\Errors::userIsBlocked();
160
+		} elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
161
+			\Errors::emailNotConfirmed();
162
+		}
163
+
164
+		return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
165
+	}
166
+
167
+	/**
168
+	 * Handle a social login request of the none admin to the application.
169
+	 *
170
+	 * @param  string $authCode
171
+	 * @param  string $accessToken
172
+	 * @param  string $type
173
+	 * @return array
174
+	 */
175
+	public function loginSocial($authCode, $accessToken, $type)
176
+	{
177
+		$access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
178
+		$user         = \Socialite::driver($type)->userFromToken($access_token);
179
+
180
+		if (! $user->email) {
181
+			\Errors::noSocialEmail();
182
+		}
183
+
184
+		if (! $this->repo->first(['email' => $user->email])) {
185
+			$this->register($user->email, '', true);
186
+		}
187
+
188
+		return $this->loginProxy->login($user->email, config('skeleton.social_pass'));
189
+	}
190 190
     
191
-    /**
192
-     * Handle a registration request.
193
-     *
194
-     * @param  string  $name
195
-     * @param  string  $email
196
-     * @param  string  $password
197
-     * @param  boolean $skipConfirmEmail
198
-     * @return array
199
-     */
200
-    public function register($name, $email, $password, $skipConfirmEmail = false)
201
-    {
202
-        $user = $this->repo->save([
203
-            'name'      => $name,
204
-            'email'     => $email,
205
-            'password'  => $password,
206
-            'confirmed' => $skipConfirmEmail
207
-        ]);
208
-
209
-        if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) {
210
-            $this->sendConfirmationEmail($user->email);
211
-        }
212
-
213
-        return $user;
214
-    }
191
+	/**
192
+	 * Handle a registration request.
193
+	 *
194
+	 * @param  string  $name
195
+	 * @param  string  $email
196
+	 * @param  string  $password
197
+	 * @param  boolean $skipConfirmEmail
198
+	 * @return array
199
+	 */
200
+	public function register($name, $email, $password, $skipConfirmEmail = false)
201
+	{
202
+		$user = $this->repo->save([
203
+			'name'      => $name,
204
+			'email'     => $email,
205
+			'password'  => $password,
206
+			'confirmed' => $skipConfirmEmail
207
+		]);
208
+
209
+		if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) {
210
+			$this->sendConfirmationEmail($user->email);
211
+		}
212
+
213
+		return $user;
214
+	}
215 215
     
216
-    /**
217
-     * Block the user.
218
-     *
219
-     * @param  integer $userId
220
-     * @return object
221
-     */
222
-    public function block($userId)
223
-    {
224
-        if (\Auth::id() == $userId || $this->hasRoles(['Admin'], $user) !== false) {
225
-            \Errors::noPermissions();
226
-        }
216
+	/**
217
+	 * Block the user.
218
+	 *
219
+	 * @param  integer $userId
220
+	 * @return object
221
+	 */
222
+	public function block($userId)
223
+	{
224
+		if (\Auth::id() == $userId || $this->hasRoles(['Admin'], $user) !== false) {
225
+			\Errors::noPermissions();
226
+		}
227 227
         
228
-        return $this->repo->save(['id' => $userId, 'blocked' => 1]);
229
-    }
230
-
231
-    /**
232
-     * Unblock the user.
233
-     *
234
-     * @param  integer $userId
235
-     * @return object
236
-     */
237
-    public function unblock($userId)
238
-    {
239
-        return $this->repo->save(['id' => $userId, 'blocked' => 0]);
240
-    }
241
-
242
-    /**
243
-     * Send a reset link to the given user.
244
-     *
245
-     * @param  string  $email
246
-     * @return void
247
-     */
248
-    public function sendReset($email)
249
-    {
250
-        if (! $user = $this->repo->first(['email' => $email])) {
251
-            \Errors::notFound('email');
252
-        }
253
-
254
-        $token = \Password::getService()->create($user);
255
-        $this->notificationService->notify($user, 'ResetPassword', $token);
256
-    }
257
-
258
-    /**
259
-     * Reset the given user's password.
260
-     *
261
-     * @param   string  $email
262
-     * @param   string  $password
263
-     * @param   string  $passwordConfirmation
264
-     * @param   string  $token
265
-     * @return string|void
266
-     */
267
-    public function resetPassword($email, $password, $passwordConfirmation, $token)
268
-    {
269
-        $response = \Password::reset([
270
-            'email'                 => $email,
271
-            'password'              => $password,
272
-            'password_confirmation' => $passwordConfirmation,
273
-            'token'                 => $token
274
-        ], function ($user, $password) {
275
-            $this->repo->save(['id' => $user->id, 'password' => $password]);
276
-        });
277
-
278
-        switch ($response) {
279
-            case \Password::PASSWORD_RESET:
280
-                return 'success';
281
-                break;
282
-
283
-            case \Password::INVALID_TOKEN:
284
-                \Errors::invalidResetToken();
285
-                break;
286
-
287
-            case \Password::INVALID_PASSWORD:
288
-                \Errors::invalidResetPassword();
289
-                break;
290
-
291
-            case \Password::INVALID_USER:
292
-                \Errors::notFound('user');
293
-                break;
294
-        }
295
-    }
296
-
297
-    /**
298
-     * Change the logged in user password.
299
-     *
300
-     * @param  string  $password
301
-     * @param  string  $oldPassword
302
-     * @return void
303
-     */
304
-    public function changePassword($password, $oldPassword)
305
-    {
306
-        $user = \Auth::user();
307
-        if (! \Hash::check($oldPassword, $user->password)) {
308
-            \Errors::invalidOldPassword();
309
-        }
310
-
311
-        $this->repo->save(['id' => $user->id, 'password' => $password]);
312
-    }
313
-
314
-    /**
315
-     * Confirm email using the confirmation code.
316
-     *
317
-     * @param  string $confirmationCode
318
-     * @return void
319
-     */
320
-    public function confirmEmail($confirmationCode)
321
-    {
322
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
323
-            \Errors::invalidConfirmationCode();
324
-        }
325
-
326
-        $this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
327
-    }
328
-
329
-    /**
330
-     * Send the confirmation mail.
331
-     *
332
-     * @param  string $email
333
-     * @return void
334
-     */
335
-    public function sendConfirmationEmail($email)
336
-    {
337
-        $user = $this->repo->first(['email' => $email]);
338
-        if ($user->confirmed) {
339
-            \Errors::emailAlreadyConfirmed();
340
-        }
341
-
342
-        $this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
343
-        $this->notificationService->notify($user, 'ConfirmEmail');
344
-    }
345
-
346
-    /**
347
-     * Save the given data to the logged in user.
348
-     *
349
-     * @param  string $name
350
-     * @param  string $email
351
-     * @param  string $profilePicture
352
-     * @return void
353
-     */
354
-    public function saveProfile($name, $email, $profilePicture = false)
355
-    {
356
-        if ($profilePicture) {
357
-            $data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'admins/profile_pictures');
358
-        }
228
+		return $this->repo->save(['id' => $userId, 'blocked' => 1]);
229
+	}
230
+
231
+	/**
232
+	 * Unblock the user.
233
+	 *
234
+	 * @param  integer $userId
235
+	 * @return object
236
+	 */
237
+	public function unblock($userId)
238
+	{
239
+		return $this->repo->save(['id' => $userId, 'blocked' => 0]);
240
+	}
241
+
242
+	/**
243
+	 * Send a reset link to the given user.
244
+	 *
245
+	 * @param  string  $email
246
+	 * @return void
247
+	 */
248
+	public function sendReset($email)
249
+	{
250
+		if (! $user = $this->repo->first(['email' => $email])) {
251
+			\Errors::notFound('email');
252
+		}
253
+
254
+		$token = \Password::getService()->create($user);
255
+		$this->notificationService->notify($user, 'ResetPassword', $token);
256
+	}
257
+
258
+	/**
259
+	 * Reset the given user's password.
260
+	 *
261
+	 * @param   string  $email
262
+	 * @param   string  $password
263
+	 * @param   string  $passwordConfirmation
264
+	 * @param   string  $token
265
+	 * @return string|void
266
+	 */
267
+	public function resetPassword($email, $password, $passwordConfirmation, $token)
268
+	{
269
+		$response = \Password::reset([
270
+			'email'                 => $email,
271
+			'password'              => $password,
272
+			'password_confirmation' => $passwordConfirmation,
273
+			'token'                 => $token
274
+		], function ($user, $password) {
275
+			$this->repo->save(['id' => $user->id, 'password' => $password]);
276
+		});
277
+
278
+		switch ($response) {
279
+			case \Password::PASSWORD_RESET:
280
+				return 'success';
281
+				break;
282
+
283
+			case \Password::INVALID_TOKEN:
284
+				\Errors::invalidResetToken();
285
+				break;
286
+
287
+			case \Password::INVALID_PASSWORD:
288
+				\Errors::invalidResetPassword();
289
+				break;
290
+
291
+			case \Password::INVALID_USER:
292
+				\Errors::notFound('user');
293
+				break;
294
+		}
295
+	}
296
+
297
+	/**
298
+	 * Change the logged in user password.
299
+	 *
300
+	 * @param  string  $password
301
+	 * @param  string  $oldPassword
302
+	 * @return void
303
+	 */
304
+	public function changePassword($password, $oldPassword)
305
+	{
306
+		$user = \Auth::user();
307
+		if (! \Hash::check($oldPassword, $user->password)) {
308
+			\Errors::invalidOldPassword();
309
+		}
310
+
311
+		$this->repo->save(['id' => $user->id, 'password' => $password]);
312
+	}
313
+
314
+	/**
315
+	 * Confirm email using the confirmation code.
316
+	 *
317
+	 * @param  string $confirmationCode
318
+	 * @return void
319
+	 */
320
+	public function confirmEmail($confirmationCode)
321
+	{
322
+		if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
323
+			\Errors::invalidConfirmationCode();
324
+		}
325
+
326
+		$this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
327
+	}
328
+
329
+	/**
330
+	 * Send the confirmation mail.
331
+	 *
332
+	 * @param  string $email
333
+	 * @return void
334
+	 */
335
+	public function sendConfirmationEmail($email)
336
+	{
337
+		$user = $this->repo->first(['email' => $email]);
338
+		if ($user->confirmed) {
339
+			\Errors::emailAlreadyConfirmed();
340
+		}
341
+
342
+		$this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
343
+		$this->notificationService->notify($user, 'ConfirmEmail');
344
+	}
345
+
346
+	/**
347
+	 * Save the given data to the logged in user.
348
+	 *
349
+	 * @param  string $name
350
+	 * @param  string $email
351
+	 * @param  string $profilePicture
352
+	 * @return void
353
+	 */
354
+	public function saveProfile($name, $email, $profilePicture = false)
355
+	{
356
+		if ($profilePicture) {
357
+			$data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'admins/profile_pictures');
358
+		}
359 359
         
360
-        $data['id'] = \Auth::id();
361
-        return $this->repo->save([
362
-            'id'             => \Auth::id(),
363
-            'name'           => $name,
364
-            'email'          => $email,
365
-            'profilePicture' => $profilePicture,
366
-        ]);
367
-    }
368
-
369
-    /**
370
-     * Logs out the user, revoke access token and refresh token.
371
-     *
372
-     * @return void
373
-     */
374
-    public function logout()
375
-    {
376
-        $this->oauthClientService->revokeAccessToken(\Auth::user()->token());
377
-    }
378
-
379
-    /**
380
-     * Attempt to refresh the access token using the given refresh token.
381
-     *
382
-     * @param  string $refreshToken
383
-     * @return array
384
-     */
385
-    public function refreshToken($refreshToken)
386
-    {
387
-        return $this->loginProxy->refreshToken($refreshToken);
388
-    }
360
+		$data['id'] = \Auth::id();
361
+		return $this->repo->save([
362
+			'id'             => \Auth::id(),
363
+			'name'           => $name,
364
+			'email'          => $email,
365
+			'profilePicture' => $profilePicture,
366
+		]);
367
+	}
368
+
369
+	/**
370
+	 * Logs out the user, revoke access token and refresh token.
371
+	 *
372
+	 * @return void
373
+	 */
374
+	public function logout()
375
+	{
376
+		$this->oauthClientService->revokeAccessToken(\Auth::user()->token());
377
+	}
378
+
379
+	/**
380
+	 * Attempt to refresh the access token using the given refresh token.
381
+	 *
382
+	 * @param  string $refreshToken
383
+	 * @return array
384
+	 */
385
+	public function refreshToken($refreshToken)
386
+	{
387
+		return $this->loginProxy->refreshToken($refreshToken);
388
+	}
389 389
 }
Please login to merge, or discard this patch.
src/Modules/Reporting/Services/ReportService.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@
 block discarded – undo
8 8
 
9 9
 class ReportService extends BaseService
10 10
 {
11
-    /**
12
-     * @var UserService
13
-     */
14
-    protected $userService;
11
+	/**
12
+	 * @var UserService
13
+	 */
14
+	protected $userService;
15 15
 
16
-    /**
17
-     * Init new object.
18
-     *
19
-     * @param   ReportRepository $repo
20
-     * @return  void
21
-     */
22
-    public function __construct(ReportRepository $repo, UserService $userService)
23
-    {
24
-        $this->userService = $userService;
25
-        parent::__construct($repo);
26
-    }
16
+	/**
17
+	 * Init new object.
18
+	 *
19
+	 * @param   ReportRepository $repo
20
+	 * @return  void
21
+	 */
22
+	public function __construct(ReportRepository $repo, UserService $userService)
23
+	{
24
+		$this->userService = $userService;
25
+		parent::__construct($repo);
26
+	}
27 27
 
28
-    /**
29
-     * Render the given report db view based on the given
30
-     * condition.
31
-     *
32
-     * @param  string  $reportName
33
-     * @param  array   $conditions
34
-     * @param  integer $perPage
35
-     * @param  boolean $skipPermission
36
-     * @return object
37
-     */
38
-    public function getReport($reportName, $conditions = [], $perPage = 0, $skipPermission = false)
39
-    {
40
-        /**
41
-         * Fetch the report from db.
42
-         */
43
-        $report = $this->repo->first(['report_name' => $reportName]);
28
+	/**
29
+	 * Render the given report db view based on the given
30
+	 * condition.
31
+	 *
32
+	 * @param  string  $reportName
33
+	 * @param  array   $conditions
34
+	 * @param  integer $perPage
35
+	 * @param  boolean $skipPermission
36
+	 * @return object
37
+	 */
38
+	public function getReport($reportName, $conditions = [], $perPage = 0, $skipPermission = false)
39
+	{
40
+		/**
41
+		 * Fetch the report from db.
42
+		 */
43
+		$report = $this->repo->first(['report_name' => $reportName]);
44 44
 
45
-        /**
46
-         * Check report existance and permission.
47
-         */
48
-        if (! $report) {
49
-            \Errors::notFound('report');
50
-        } elseif (! $skipPermission && ! $this->userService->can($report->view_name, 'report')) {
51
-            \Errors::noPermissions();
52
-        }
45
+		/**
46
+		 * Check report existance and permission.
47
+		 */
48
+		if (! $report) {
49
+			\Errors::notFound('report');
50
+		} elseif (! $skipPermission && ! $this->userService->can($report->view_name, 'report')) {
51
+			\Errors::noPermissions();
52
+		}
53 53
 
54
-        return $this->repo->renderReport($report, $conditions, $perPage);
55
-    }
54
+		return $this->repo->renderReport($report, $conditions, $perPage);
55
+	}
56 56
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Resources/Lang/en/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/Roles/Resources/Lang/ar/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/Notifications/Resources/Lang/en/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/Notifications/Resources/Lang/ar/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/PushNotificationDevices/Resources/Lang/en/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/PushNotificationDevices/Resources/Lang/ar/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.
src/Modules/OauthClients/Resources/Lang/en/errors.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 error messages.
7
-     */
5
+	/**
6
+	 * Here goes your error messages.
7
+	 */
8 8
 
9 9
 ];
Please login to merge, or discard this patch.