@@ -10,382 +10,382 @@ |
||
10 | 10 | |
11 | 11 | class UserService extends BaseService |
12 | 12 | { |
13 | - /** |
|
14 | - * @var PermissionService |
|
15 | - */ |
|
16 | - protected $permissionService; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var LoginProxy |
|
20 | - */ |
|
21 | - protected $loginProxy; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var NotificationService |
|
25 | - */ |
|
26 | - protected $notificationService; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var OauthClientService |
|
30 | - */ |
|
31 | - protected $oauthClientService; |
|
32 | - |
|
33 | - /** |
|
34 | - * Init new object. |
|
35 | - * |
|
36 | - * @param UserRepository $repo |
|
37 | - * @param PermissionService $permissionService |
|
38 | - * @param LoginProxy $loginProxy |
|
39 | - * @param NotificationService $notificationService |
|
40 | - * @param OauthClientService $oauthClientService |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function __construct( |
|
44 | - UserRepository $repo, |
|
45 | - PermissionService $permissionService, |
|
46 | - LoginProxy $loginProxy, |
|
47 | - NotificationService $notificationService, |
|
48 | - OauthClientService $oauthClientService) |
|
49 | - { |
|
50 | - $this->permissionService = $permissionService; |
|
51 | - $this->loginProxy = $loginProxy; |
|
52 | - $this->notificationService = $notificationService; |
|
53 | - $this->oauthClientService = $oauthClientService; |
|
54 | - parent::__construct($repo); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Return the logged in user account. |
|
59 | - * |
|
60 | - * @param array $relations |
|
61 | - * @return boolean |
|
62 | - */ |
|
63 | - public function account($relations = ['roles.permissions']) |
|
64 | - { |
|
65 | - $permissions = []; |
|
66 | - $user = $this->repo->find(\Auth::id(), $relations); |
|
67 | - foreach ($user->roles as $role) { |
|
68 | - $role->permissions->each(function ($permission) use (&$permissions) { |
|
69 | - $permissions[$permission->repo][$permission->id] = $permission->name; |
|
70 | - }); |
|
71 | - } |
|
72 | - $user->permissions = $permissions; |
|
73 | - |
|
74 | - return $user; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Check if the logged in user or the given user |
|
79 | - * has the given permissions on the given model. |
|
80 | - * |
|
81 | - * @param string $permissionName |
|
82 | - * @param string $model |
|
83 | - * @param mixed $userId |
|
84 | - * @return boolean |
|
85 | - */ |
|
86 | - public function can($permissionName, $model, $userId = false) |
|
87 | - { |
|
88 | - $permission = $this->permissionService->first([ |
|
89 | - 'and' => [ |
|
90 | - 'model' => $model, |
|
91 | - 'name' => $permissionName, |
|
92 | - 'roles' => [ |
|
93 | - 'op' => 'has', |
|
94 | - 'val' => [ |
|
95 | - 'users' => [ |
|
96 | - 'op' => 'has', |
|
97 | - 'val' => [ |
|
98 | - 'users.id' => $userId ?: \Auth::id() |
|
99 | - ] |
|
100 | - ] |
|
101 | - ] |
|
102 | - ] |
|
103 | - ] |
|
104 | - ]); |
|
105 | - |
|
106 | - return $permission ? true : false; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Check if the logged in or the given user has the given role. |
|
111 | - * |
|
112 | - * @param string[] $roles |
|
113 | - * @param mixed $user |
|
114 | - * @return boolean |
|
115 | - */ |
|
116 | - public function hasRoles($roles, $user = false) |
|
117 | - { |
|
118 | - return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Assign the given role ids to the given user. |
|
123 | - * |
|
124 | - * @param integer $userId |
|
125 | - * @param array $roleIds |
|
126 | - * @return object |
|
127 | - */ |
|
128 | - public function assignRoles($userId, $roleIds) |
|
129 | - { |
|
130 | - $user = false; |
|
131 | - \DB::transaction(function () use ($userId, $permissionIds, &$user) { |
|
132 | - $user = $this->repo->find($userId); |
|
133 | - $this->repo->detachPermissions($userId); |
|
134 | - $this->repo->attachPermissions($userId, $roleIds); |
|
135 | - }); |
|
136 | - |
|
137 | - return $user; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Handle a login request to the application. |
|
142 | - * |
|
143 | - * @param string $email |
|
144 | - * @param string $password |
|
145 | - * @param boolean $adminLogin |
|
146 | - * @return object |
|
147 | - */ |
|
148 | - public function login($email, $password, $adminLogin = false) |
|
149 | - { |
|
150 | - if (! $user = $this->repo->first(['email' => $email])) { |
|
151 | - \Errors::loginFailed(); |
|
152 | - } elseif ($adminLogin && ! $this->hasRoles(['Admin'], $user)) { |
|
153 | - \Errors::loginFailed(); |
|
154 | - } elseif (! $adminLogin && $this->hasRoles(['Admin'], $user)) { |
|
155 | - \Errors::loginFailed(); |
|
156 | - } elseif ($user->blocked) { |
|
157 | - \Errors::userIsBlocked(); |
|
158 | - } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
159 | - \Errors::emailNotConfirmed(); |
|
160 | - } |
|
161 | - |
|
162 | - return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)]; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Handle a social login request of the none admin to the application. |
|
167 | - * |
|
168 | - * @param string $authCode |
|
169 | - * @param string $accessToken |
|
170 | - * @param string $type |
|
171 | - * @return array |
|
172 | - */ |
|
173 | - public function loginSocial($authCode, $accessToken, $type) |
|
174 | - { |
|
175 | - $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
|
176 | - $user = \Socialite::driver($type)->userFromToken($access_token); |
|
177 | - |
|
178 | - if (! $user->email) { |
|
179 | - \Errors::noSocialEmail(); |
|
180 | - } |
|
181 | - |
|
182 | - if (! $this->repo->first(['email' => $user->email])) { |
|
183 | - $this->register(['email' => $user->email, 'password' => ''], true); |
|
184 | - } |
|
185 | - |
|
186 | - return $this->loginProxy->login($user->email, config('skeleton.social_pass')); |
|
187 | - } |
|
13 | + /** |
|
14 | + * @var PermissionService |
|
15 | + */ |
|
16 | + protected $permissionService; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var LoginProxy |
|
20 | + */ |
|
21 | + protected $loginProxy; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var NotificationService |
|
25 | + */ |
|
26 | + protected $notificationService; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var OauthClientService |
|
30 | + */ |
|
31 | + protected $oauthClientService; |
|
32 | + |
|
33 | + /** |
|
34 | + * Init new object. |
|
35 | + * |
|
36 | + * @param UserRepository $repo |
|
37 | + * @param PermissionService $permissionService |
|
38 | + * @param LoginProxy $loginProxy |
|
39 | + * @param NotificationService $notificationService |
|
40 | + * @param OauthClientService $oauthClientService |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function __construct( |
|
44 | + UserRepository $repo, |
|
45 | + PermissionService $permissionService, |
|
46 | + LoginProxy $loginProxy, |
|
47 | + NotificationService $notificationService, |
|
48 | + OauthClientService $oauthClientService) |
|
49 | + { |
|
50 | + $this->permissionService = $permissionService; |
|
51 | + $this->loginProxy = $loginProxy; |
|
52 | + $this->notificationService = $notificationService; |
|
53 | + $this->oauthClientService = $oauthClientService; |
|
54 | + parent::__construct($repo); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Return the logged in user account. |
|
59 | + * |
|
60 | + * @param array $relations |
|
61 | + * @return boolean |
|
62 | + */ |
|
63 | + public function account($relations = ['roles.permissions']) |
|
64 | + { |
|
65 | + $permissions = []; |
|
66 | + $user = $this->repo->find(\Auth::id(), $relations); |
|
67 | + foreach ($user->roles as $role) { |
|
68 | + $role->permissions->each(function ($permission) use (&$permissions) { |
|
69 | + $permissions[$permission->repo][$permission->id] = $permission->name; |
|
70 | + }); |
|
71 | + } |
|
72 | + $user->permissions = $permissions; |
|
73 | + |
|
74 | + return $user; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Check if the logged in user or the given user |
|
79 | + * has the given permissions on the given model. |
|
80 | + * |
|
81 | + * @param string $permissionName |
|
82 | + * @param string $model |
|
83 | + * @param mixed $userId |
|
84 | + * @return boolean |
|
85 | + */ |
|
86 | + public function can($permissionName, $model, $userId = false) |
|
87 | + { |
|
88 | + $permission = $this->permissionService->first([ |
|
89 | + 'and' => [ |
|
90 | + 'model' => $model, |
|
91 | + 'name' => $permissionName, |
|
92 | + 'roles' => [ |
|
93 | + 'op' => 'has', |
|
94 | + 'val' => [ |
|
95 | + 'users' => [ |
|
96 | + 'op' => 'has', |
|
97 | + 'val' => [ |
|
98 | + 'users.id' => $userId ?: \Auth::id() |
|
99 | + ] |
|
100 | + ] |
|
101 | + ] |
|
102 | + ] |
|
103 | + ] |
|
104 | + ]); |
|
105 | + |
|
106 | + return $permission ? true : false; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Check if the logged in or the given user has the given role. |
|
111 | + * |
|
112 | + * @param string[] $roles |
|
113 | + * @param mixed $user |
|
114 | + * @return boolean |
|
115 | + */ |
|
116 | + public function hasRoles($roles, $user = false) |
|
117 | + { |
|
118 | + return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Assign the given role ids to the given user. |
|
123 | + * |
|
124 | + * @param integer $userId |
|
125 | + * @param array $roleIds |
|
126 | + * @return object |
|
127 | + */ |
|
128 | + public function assignRoles($userId, $roleIds) |
|
129 | + { |
|
130 | + $user = false; |
|
131 | + \DB::transaction(function () use ($userId, $permissionIds, &$user) { |
|
132 | + $user = $this->repo->find($userId); |
|
133 | + $this->repo->detachPermissions($userId); |
|
134 | + $this->repo->attachPermissions($userId, $roleIds); |
|
135 | + }); |
|
136 | + |
|
137 | + return $user; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Handle a login request to the application. |
|
142 | + * |
|
143 | + * @param string $email |
|
144 | + * @param string $password |
|
145 | + * @param boolean $adminLogin |
|
146 | + * @return object |
|
147 | + */ |
|
148 | + public function login($email, $password, $adminLogin = false) |
|
149 | + { |
|
150 | + if (! $user = $this->repo->first(['email' => $email])) { |
|
151 | + \Errors::loginFailed(); |
|
152 | + } elseif ($adminLogin && ! $this->hasRoles(['Admin'], $user)) { |
|
153 | + \Errors::loginFailed(); |
|
154 | + } elseif (! $adminLogin && $this->hasRoles(['Admin'], $user)) { |
|
155 | + \Errors::loginFailed(); |
|
156 | + } elseif ($user->blocked) { |
|
157 | + \Errors::userIsBlocked(); |
|
158 | + } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
159 | + \Errors::emailNotConfirmed(); |
|
160 | + } |
|
161 | + |
|
162 | + return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)]; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Handle a social login request of the none admin to the application. |
|
167 | + * |
|
168 | + * @param string $authCode |
|
169 | + * @param string $accessToken |
|
170 | + * @param string $type |
|
171 | + * @return array |
|
172 | + */ |
|
173 | + public function loginSocial($authCode, $accessToken, $type) |
|
174 | + { |
|
175 | + $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
|
176 | + $user = \Socialite::driver($type)->userFromToken($access_token); |
|
177 | + |
|
178 | + if (! $user->email) { |
|
179 | + \Errors::noSocialEmail(); |
|
180 | + } |
|
181 | + |
|
182 | + if (! $this->repo->first(['email' => $user->email])) { |
|
183 | + $this->register(['email' => $user->email, 'password' => ''], true); |
|
184 | + } |
|
185 | + |
|
186 | + return $this->loginProxy->login($user->email, config('skeleton.social_pass')); |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Handle a registration request. |
|
191 | - * |
|
192 | - * @param string $name |
|
193 | - * @param string $email |
|
194 | - * @param string $password |
|
195 | - * @param boolean $skipConfirmEmail |
|
196 | - * @return array |
|
197 | - */ |
|
198 | - public function register($name, $email, $password, $skipConfirmEmail = false) |
|
199 | - { |
|
200 | - $user = $this->repo->save([ |
|
201 | - 'name' => $name, |
|
202 | - 'email' => $email, |
|
203 | - 'password' => $password, |
|
204 | - 'confirmed' => $skipConfirmEmail |
|
205 | - ]); |
|
206 | - |
|
207 | - if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) { |
|
208 | - $this->sendConfirmationEmail($user->email); |
|
209 | - } |
|
210 | - |
|
211 | - return $user; |
|
212 | - } |
|
189 | + /** |
|
190 | + * Handle a registration request. |
|
191 | + * |
|
192 | + * @param string $name |
|
193 | + * @param string $email |
|
194 | + * @param string $password |
|
195 | + * @param boolean $skipConfirmEmail |
|
196 | + * @return array |
|
197 | + */ |
|
198 | + public function register($name, $email, $password, $skipConfirmEmail = false) |
|
199 | + { |
|
200 | + $user = $this->repo->save([ |
|
201 | + 'name' => $name, |
|
202 | + 'email' => $email, |
|
203 | + 'password' => $password, |
|
204 | + 'confirmed' => $skipConfirmEmail |
|
205 | + ]); |
|
206 | + |
|
207 | + if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) { |
|
208 | + $this->sendConfirmationEmail($user->email); |
|
209 | + } |
|
210 | + |
|
211 | + return $user; |
|
212 | + } |
|
213 | 213 | |
214 | - /** |
|
215 | - * Block the user. |
|
216 | - * |
|
217 | - * @param integer $userId |
|
218 | - * @return object |
|
219 | - */ |
|
220 | - public function block($userId) |
|
221 | - { |
|
222 | - if (\Auth::id() == $userId || $this->hasRoles(['Admin'], $user) !== false) { |
|
223 | - \Errors::noPermissions(); |
|
224 | - } |
|
214 | + /** |
|
215 | + * Block the user. |
|
216 | + * |
|
217 | + * @param integer $userId |
|
218 | + * @return object |
|
219 | + */ |
|
220 | + public function block($userId) |
|
221 | + { |
|
222 | + if (\Auth::id() == $userId || $this->hasRoles(['Admin'], $user) !== false) { |
|
223 | + \Errors::noPermissions(); |
|
224 | + } |
|
225 | 225 | |
226 | - return $this->repo->save(['id' => $userId, 'blocked' => 1]); |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Unblock the user. |
|
231 | - * |
|
232 | - * @param integer $userId |
|
233 | - * @return object |
|
234 | - */ |
|
235 | - public function unblock($userId) |
|
236 | - { |
|
237 | - return $this->repo->save(['id' => $userId, 'blocked' => 0]); |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * Send a reset link to the given user. |
|
242 | - * |
|
243 | - * @param string $email |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - public function sendReset($email) |
|
247 | - { |
|
248 | - if (! $user = $this->repo->first(['email' => $email])) { |
|
249 | - \Errors::notFound('email'); |
|
250 | - } |
|
251 | - |
|
252 | - $token = \Password::getService()->create($user); |
|
253 | - $this->notificationService->notify($user, 'ResetPassword', $token); |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Reset the given user's password. |
|
258 | - * |
|
259 | - * @param string $email |
|
260 | - * @param string $password |
|
261 | - * @param string $passwordConfirmation |
|
262 | - * @param string $token |
|
263 | - * @return string|void |
|
264 | - */ |
|
265 | - public function resetPassword($email, $password, $passwordConfirmation, $token) |
|
266 | - { |
|
267 | - $response = \Password::reset([ |
|
268 | - 'email' => $email, |
|
269 | - 'password' => $password, |
|
270 | - 'password_confirmation' => $passwordConfirmation, |
|
271 | - 'token' => $token |
|
272 | - ], function ($user, $password) { |
|
273 | - $this->repo->save(['id' => $user->id, 'password' => $password]); |
|
274 | - }); |
|
275 | - |
|
276 | - switch ($response) { |
|
277 | - case \Password::PASSWORD_RESET: |
|
278 | - return 'success'; |
|
279 | - break; |
|
280 | - |
|
281 | - case \Password::INVALID_TOKEN: |
|
282 | - \Errors::invalidResetToken('token'); |
|
283 | - break; |
|
284 | - |
|
285 | - case \Password::INVALID_PASSWORD: |
|
286 | - \Errors::invalidResetPassword('email'); |
|
287 | - break; |
|
288 | - |
|
289 | - case \Password::INVALID_USER: |
|
290 | - \Errors::notFound('user'); |
|
291 | - break; |
|
292 | - |
|
293 | - default: |
|
294 | - \Errors::generalError(); |
|
295 | - break; |
|
296 | - } |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * Change the logged in user password. |
|
301 | - * |
|
302 | - * @param string $password |
|
303 | - * @param string $oldPassword |
|
304 | - * @return void |
|
305 | - */ |
|
306 | - public function changePassword($password, $oldPassword) |
|
307 | - { |
|
308 | - $user = \Auth::user(); |
|
309 | - if (! \Hash::check($oldPassword, $user->password)) { |
|
310 | - \Errors::invalidOldPassword(); |
|
311 | - } |
|
312 | - |
|
313 | - $this->repo->save(['id' => $user->id, 'password' => $password]); |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Confirm email using the confirmation code. |
|
318 | - * |
|
319 | - * @param string $confirmationCode |
|
320 | - * @return void |
|
321 | - */ |
|
322 | - public function confirmEmail($confirmationCode) |
|
323 | - { |
|
324 | - if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) { |
|
325 | - \Errors::invalidConfirmationCode(); |
|
326 | - } |
|
327 | - |
|
328 | - $this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]); |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * Send the confirmation mail. |
|
333 | - * |
|
334 | - * @param string $email |
|
335 | - * @return void |
|
336 | - */ |
|
337 | - public function sendConfirmationEmail($email) |
|
338 | - { |
|
339 | - $user = $this->repo->first(['email' => $email]); |
|
340 | - if ($user->confirmed) { |
|
341 | - \Errors::emailAlreadyConfirmed(); |
|
342 | - } |
|
343 | - |
|
344 | - $this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]); |
|
345 | - $this->notificationService->notify($user, 'ConfirmEmail'); |
|
346 | - } |
|
347 | - |
|
348 | - /** |
|
349 | - * Save the given data to the logged in user. |
|
350 | - * |
|
351 | - * @param string $name |
|
352 | - * @param string $email |
|
353 | - * @param string $profilePicture |
|
354 | - * @return void |
|
355 | - */ |
|
356 | - public function saveProfile($name, $email, $profilePicture = false) |
|
357 | - { |
|
358 | - if ($profilePicture) { |
|
359 | - $data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'admins/profile_pictures'); |
|
360 | - } |
|
226 | + return $this->repo->save(['id' => $userId, 'blocked' => 1]); |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Unblock the user. |
|
231 | + * |
|
232 | + * @param integer $userId |
|
233 | + * @return object |
|
234 | + */ |
|
235 | + public function unblock($userId) |
|
236 | + { |
|
237 | + return $this->repo->save(['id' => $userId, 'blocked' => 0]); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Send a reset link to the given user. |
|
242 | + * |
|
243 | + * @param string $email |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + public function sendReset($email) |
|
247 | + { |
|
248 | + if (! $user = $this->repo->first(['email' => $email])) { |
|
249 | + \Errors::notFound('email'); |
|
250 | + } |
|
251 | + |
|
252 | + $token = \Password::getService()->create($user); |
|
253 | + $this->notificationService->notify($user, 'ResetPassword', $token); |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Reset the given user's password. |
|
258 | + * |
|
259 | + * @param string $email |
|
260 | + * @param string $password |
|
261 | + * @param string $passwordConfirmation |
|
262 | + * @param string $token |
|
263 | + * @return string|void |
|
264 | + */ |
|
265 | + public function resetPassword($email, $password, $passwordConfirmation, $token) |
|
266 | + { |
|
267 | + $response = \Password::reset([ |
|
268 | + 'email' => $email, |
|
269 | + 'password' => $password, |
|
270 | + 'password_confirmation' => $passwordConfirmation, |
|
271 | + 'token' => $token |
|
272 | + ], function ($user, $password) { |
|
273 | + $this->repo->save(['id' => $user->id, 'password' => $password]); |
|
274 | + }); |
|
275 | + |
|
276 | + switch ($response) { |
|
277 | + case \Password::PASSWORD_RESET: |
|
278 | + return 'success'; |
|
279 | + break; |
|
280 | + |
|
281 | + case \Password::INVALID_TOKEN: |
|
282 | + \Errors::invalidResetToken('token'); |
|
283 | + break; |
|
284 | + |
|
285 | + case \Password::INVALID_PASSWORD: |
|
286 | + \Errors::invalidResetPassword('email'); |
|
287 | + break; |
|
288 | + |
|
289 | + case \Password::INVALID_USER: |
|
290 | + \Errors::notFound('user'); |
|
291 | + break; |
|
292 | + |
|
293 | + default: |
|
294 | + \Errors::generalError(); |
|
295 | + break; |
|
296 | + } |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * Change the logged in user password. |
|
301 | + * |
|
302 | + * @param string $password |
|
303 | + * @param string $oldPassword |
|
304 | + * @return void |
|
305 | + */ |
|
306 | + public function changePassword($password, $oldPassword) |
|
307 | + { |
|
308 | + $user = \Auth::user(); |
|
309 | + if (! \Hash::check($oldPassword, $user->password)) { |
|
310 | + \Errors::invalidOldPassword(); |
|
311 | + } |
|
312 | + |
|
313 | + $this->repo->save(['id' => $user->id, 'password' => $password]); |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Confirm email using the confirmation code. |
|
318 | + * |
|
319 | + * @param string $confirmationCode |
|
320 | + * @return void |
|
321 | + */ |
|
322 | + public function confirmEmail($confirmationCode) |
|
323 | + { |
|
324 | + if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) { |
|
325 | + \Errors::invalidConfirmationCode(); |
|
326 | + } |
|
327 | + |
|
328 | + $this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]); |
|
329 | + } |
|
330 | + |
|
331 | + /** |
|
332 | + * Send the confirmation mail. |
|
333 | + * |
|
334 | + * @param string $email |
|
335 | + * @return void |
|
336 | + */ |
|
337 | + public function sendConfirmationEmail($email) |
|
338 | + { |
|
339 | + $user = $this->repo->first(['email' => $email]); |
|
340 | + if ($user->confirmed) { |
|
341 | + \Errors::emailAlreadyConfirmed(); |
|
342 | + } |
|
343 | + |
|
344 | + $this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]); |
|
345 | + $this->notificationService->notify($user, 'ConfirmEmail'); |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * Save the given data to the logged in user. |
|
350 | + * |
|
351 | + * @param string $name |
|
352 | + * @param string $email |
|
353 | + * @param string $profilePicture |
|
354 | + * @return void |
|
355 | + */ |
|
356 | + public function saveProfile($name, $email, $profilePicture = false) |
|
357 | + { |
|
358 | + if ($profilePicture) { |
|
359 | + $data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'admins/profile_pictures'); |
|
360 | + } |
|
361 | 361 | |
362 | - $data['id'] = \Auth::id(); |
|
363 | - return $this->repo->save([ |
|
364 | - 'id' => \Auth::id(), |
|
365 | - 'name' => $name, |
|
366 | - 'email' => $email, |
|
367 | - 'profilePicture' => $profilePicture, |
|
368 | - ]); |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Logs out the user, revoke access token and refresh token. |
|
373 | - * |
|
374 | - * @return void |
|
375 | - */ |
|
376 | - public function logout() |
|
377 | - { |
|
378 | - $this->oauthClientService->revokeAccessToken(\Auth::user()->token()); |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
382 | - * Attempt to refresh the access token using the given refresh token. |
|
383 | - * |
|
384 | - * @param string $refreshToken |
|
385 | - * @return array |
|
386 | - */ |
|
387 | - public function refreshToken($refreshToken) |
|
388 | - { |
|
389 | - return $this->loginProxy->refreshToken($refreshToken); |
|
390 | - } |
|
362 | + $data['id'] = \Auth::id(); |
|
363 | + return $this->repo->save([ |
|
364 | + 'id' => \Auth::id(), |
|
365 | + 'name' => $name, |
|
366 | + 'email' => $email, |
|
367 | + 'profilePicture' => $profilePicture, |
|
368 | + ]); |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Logs out the user, revoke access token and refresh token. |
|
373 | + * |
|
374 | + * @return void |
|
375 | + */ |
|
376 | + public function logout() |
|
377 | + { |
|
378 | + $this->oauthClientService->revokeAccessToken(\Auth::user()->token()); |
|
379 | + } |
|
380 | + |
|
381 | + /** |
|
382 | + * Attempt to refresh the access token using the given refresh token. |
|
383 | + * |
|
384 | + * @param string $refreshToken |
|
385 | + * @return array |
|
386 | + */ |
|
387 | + public function refreshToken($refreshToken) |
|
388 | + { |
|
389 | + return $this->loginProxy->refreshToken($refreshToken); |
|
390 | + } |
|
391 | 391 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $permissions = []; |
66 | 66 | $user = $this->repo->find(\Auth::id(), $relations); |
67 | 67 | foreach ($user->roles as $role) { |
68 | - $role->permissions->each(function ($permission) use (&$permissions) { |
|
68 | + $role->permissions->each(function($permission) use (&$permissions) { |
|
69 | 69 | $permissions[$permission->repo][$permission->id] = $permission->name; |
70 | 70 | }); |
71 | 71 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function assignRoles($userId, $roleIds) |
129 | 129 | { |
130 | 130 | $user = false; |
131 | - \DB::transaction(function () use ($userId, $permissionIds, &$user) { |
|
131 | + \DB::transaction(function() use ($userId, $permissionIds, &$user) { |
|
132 | 132 | $user = $this->repo->find($userId); |
133 | 133 | $this->repo->detachPermissions($userId); |
134 | 134 | $this->repo->attachPermissions($userId, $roleIds); |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function login($email, $password, $adminLogin = false) |
149 | 149 | { |
150 | - if (! $user = $this->repo->first(['email' => $email])) { |
|
150 | + if ( ! $user = $this->repo->first(['email' => $email])) { |
|
151 | 151 | \Errors::loginFailed(); |
152 | 152 | } elseif ($adminLogin && ! $this->hasRoles(['Admin'], $user)) { |
153 | 153 | \Errors::loginFailed(); |
154 | - } elseif (! $adminLogin && $this->hasRoles(['Admin'], $user)) { |
|
154 | + } elseif ( ! $adminLogin && $this->hasRoles(['Admin'], $user)) { |
|
155 | 155 | \Errors::loginFailed(); |
156 | 156 | } elseif ($user->blocked) { |
157 | 157 | \Errors::userIsBlocked(); |
158 | - } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
158 | + } elseif ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) { |
|
159 | 159 | \Errors::emailNotConfirmed(); |
160 | 160 | } |
161 | 161 | |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken; |
176 | 176 | $user = \Socialite::driver($type)->userFromToken($access_token); |
177 | 177 | |
178 | - if (! $user->email) { |
|
178 | + if ( ! $user->email) { |
|
179 | 179 | \Errors::noSocialEmail(); |
180 | 180 | } |
181 | 181 | |
182 | - if (! $this->repo->first(['email' => $user->email])) { |
|
182 | + if ( ! $this->repo->first(['email' => $user->email])) { |
|
183 | 183 | $this->register(['email' => $user->email, 'password' => ''], true); |
184 | 184 | } |
185 | 185 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | 'confirmed' => $skipConfirmEmail |
205 | 205 | ]); |
206 | 206 | |
207 | - if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) { |
|
207 | + if ( ! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) { |
|
208 | 208 | $this->sendConfirmationEmail($user->email); |
209 | 209 | } |
210 | 210 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function sendReset($email) |
247 | 247 | { |
248 | - if (! $user = $this->repo->first(['email' => $email])) { |
|
248 | + if ( ! $user = $this->repo->first(['email' => $email])) { |
|
249 | 249 | \Errors::notFound('email'); |
250 | 250 | } |
251 | 251 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | 'password' => $password, |
270 | 270 | 'password_confirmation' => $passwordConfirmation, |
271 | 271 | 'token' => $token |
272 | - ], function ($user, $password) { |
|
272 | + ], function($user, $password) { |
|
273 | 273 | $this->repo->save(['id' => $user->id, 'password' => $password]); |
274 | 274 | }); |
275 | 275 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function changePassword($password, $oldPassword) |
307 | 307 | { |
308 | 308 | $user = \Auth::user(); |
309 | - if (! \Hash::check($oldPassword, $user->password)) { |
|
309 | + if ( ! \Hash::check($oldPassword, $user->password)) { |
|
310 | 310 | \Errors::invalidOldPassword(); |
311 | 311 | } |
312 | 312 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function confirmEmail($confirmationCode) |
323 | 323 | { |
324 | - if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) { |
|
324 | + if ( ! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) { |
|
325 | 325 | \Errors::invalidConfirmationCode(); |
326 | 326 | } |
327 | 327 |
@@ -7,32 +7,32 @@ |
||
7 | 7 | class Report extends Model |
8 | 8 | { |
9 | 9 | |
10 | - use SoftDeletes; |
|
11 | - protected $table = 'reports'; |
|
12 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | - protected $hidden = ['deleted_at']; |
|
14 | - protected $guarded = ['id']; |
|
15 | - protected $fillable = ['report_name', 'view_name']; |
|
16 | - public $searchable = ['report_name', 'view_name']; |
|
10 | + use SoftDeletes; |
|
11 | + protected $table = 'reports'; |
|
12 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
13 | + protected $hidden = ['deleted_at']; |
|
14 | + protected $guarded = ['id']; |
|
15 | + protected $fillable = ['report_name', 'view_name']; |
|
16 | + public $searchable = ['report_name', 'view_name']; |
|
17 | 17 | |
18 | - public function getCreatedAtAttribute($value) |
|
19 | - { |
|
20 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | - } |
|
18 | + public function getCreatedAtAttribute($value) |
|
19 | + { |
|
20 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
21 | + } |
|
22 | 22 | |
23 | - public function getUpdatedAtAttribute($value) |
|
24 | - { |
|
25 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
26 | - } |
|
23 | + public function getUpdatedAtAttribute($value) |
|
24 | + { |
|
25 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
26 | + } |
|
27 | 27 | |
28 | - public function getDeletedAtAttribute($value) |
|
29 | - { |
|
30 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
31 | - } |
|
28 | + public function getDeletedAtAttribute($value) |
|
29 | + { |
|
30 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
31 | + } |
|
32 | 32 | |
33 | - public static function boot() |
|
34 | - { |
|
35 | - parent::boot(); |
|
36 | - Report::observe(ReportObserver::class); |
|
37 | - } |
|
33 | + public static function boot() |
|
34 | + { |
|
35 | + parent::boot(); |
|
36 | + Report::observe(ReportObserver::class); |
|
37 | + } |
|
38 | 38 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | class ReportObserver |
7 | 7 | { |
8 | 8 | |
9 | - public function saving($model) |
|
10 | - { |
|
11 | - // |
|
12 | - } |
|
13 | - |
|
14 | - public function saved($model) |
|
15 | - { |
|
16 | - // |
|
17 | - } |
|
18 | - |
|
19 | - public function creating($model) |
|
20 | - { |
|
21 | - // |
|
22 | - } |
|
23 | - |
|
24 | - public function created($model) |
|
25 | - { |
|
26 | - // |
|
27 | - } |
|
28 | - |
|
29 | - public function updating($model) |
|
30 | - { |
|
31 | - // |
|
32 | - } |
|
33 | - |
|
34 | - public function updated($model) |
|
35 | - { |
|
36 | - // |
|
37 | - } |
|
38 | - |
|
39 | - public function deleting($model) |
|
40 | - { |
|
41 | - // |
|
42 | - } |
|
43 | - |
|
44 | - public function deleted($model) |
|
45 | - { |
|
46 | - // |
|
47 | - } |
|
48 | - |
|
49 | - public function restoring($model) |
|
50 | - { |
|
51 | - // |
|
52 | - } |
|
53 | - |
|
54 | - public function restored($model) |
|
55 | - { |
|
56 | - // |
|
57 | - } |
|
9 | + public function saving($model) |
|
10 | + { |
|
11 | + // |
|
12 | + } |
|
13 | + |
|
14 | + public function saved($model) |
|
15 | + { |
|
16 | + // |
|
17 | + } |
|
18 | + |
|
19 | + public function creating($model) |
|
20 | + { |
|
21 | + // |
|
22 | + } |
|
23 | + |
|
24 | + public function created($model) |
|
25 | + { |
|
26 | + // |
|
27 | + } |
|
28 | + |
|
29 | + public function updating($model) |
|
30 | + { |
|
31 | + // |
|
32 | + } |
|
33 | + |
|
34 | + public function updated($model) |
|
35 | + { |
|
36 | + // |
|
37 | + } |
|
38 | + |
|
39 | + public function deleting($model) |
|
40 | + { |
|
41 | + // |
|
42 | + } |
|
43 | + |
|
44 | + public function deleted($model) |
|
45 | + { |
|
46 | + // |
|
47 | + } |
|
48 | + |
|
49 | + public function restoring($model) |
|
50 | + { |
|
51 | + // |
|
52 | + } |
|
53 | + |
|
54 | + public function restored($model) |
|
55 | + { |
|
56 | + // |
|
57 | + } |
|
58 | 58 | } |
@@ -6,49 +6,49 @@ |
||
6 | 6 | |
7 | 7 | class ReportService extends BaseService |
8 | 8 | { |
9 | - /** |
|
10 | - * @var UserService |
|
11 | - */ |
|
12 | - protected $userService; |
|
9 | + /** |
|
10 | + * @var UserService |
|
11 | + */ |
|
12 | + protected $userService; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Init new object. |
|
16 | - * |
|
17 | - * @param ReportRepository $repo |
|
18 | - * @return void |
|
19 | - */ |
|
20 | - public function __construct(ReportRepository $repo, UserService $userService) |
|
21 | - { |
|
22 | - $this->userService = $userService; |
|
23 | - parent::__construct($repo); |
|
24 | - } |
|
14 | + /** |
|
15 | + * Init new object. |
|
16 | + * |
|
17 | + * @param ReportRepository $repo |
|
18 | + * @return void |
|
19 | + */ |
|
20 | + public function __construct(ReportRepository $repo, UserService $userService) |
|
21 | + { |
|
22 | + $this->userService = $userService; |
|
23 | + parent::__construct($repo); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Render the given report db view based on the given |
|
28 | - * condition. |
|
29 | - * |
|
30 | - * @param string $reportName |
|
31 | - * @param array $conditions |
|
32 | - * @param integer $perPage |
|
33 | - * @param boolean $skipPermission |
|
34 | - * @return object |
|
35 | - */ |
|
36 | - public function getReport($reportName, $conditions = [], $perPage = 0, $skipPermission = false) |
|
37 | - { |
|
38 | - /** |
|
39 | - * Fetch the report from db. |
|
40 | - */ |
|
41 | - $report = $this->repo->first(['report_name' => $reportName]); |
|
26 | + /** |
|
27 | + * Render the given report db view based on the given |
|
28 | + * condition. |
|
29 | + * |
|
30 | + * @param string $reportName |
|
31 | + * @param array $conditions |
|
32 | + * @param integer $perPage |
|
33 | + * @param boolean $skipPermission |
|
34 | + * @return object |
|
35 | + */ |
|
36 | + public function getReport($reportName, $conditions = [], $perPage = 0, $skipPermission = false) |
|
37 | + { |
|
38 | + /** |
|
39 | + * Fetch the report from db. |
|
40 | + */ |
|
41 | + $report = $this->repo->first(['report_name' => $reportName]); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Check report existance and permission. |
|
45 | - */ |
|
46 | - if (! $report) { |
|
47 | - \Errors::notFound('report'); |
|
48 | - } elseif (! $skipPermission && ! $this->userService->can($report->view_name, 'report')) { |
|
49 | - \Errors::noPermissions(); |
|
50 | - } |
|
43 | + /** |
|
44 | + * Check report existance and permission. |
|
45 | + */ |
|
46 | + if (! $report) { |
|
47 | + \Errors::notFound('report'); |
|
48 | + } elseif (! $skipPermission && ! $this->userService->can($report->view_name, 'report')) { |
|
49 | + \Errors::noPermissions(); |
|
50 | + } |
|
51 | 51 | |
52 | - return $this->repo->renderReport($report, $conditions, $perPage); |
|
53 | - } |
|
52 | + return $this->repo->renderReport($report, $conditions, $perPage); |
|
53 | + } |
|
54 | 54 | } |
@@ -43,9 +43,9 @@ |
||
43 | 43 | /** |
44 | 44 | * Check report existance and permission. |
45 | 45 | */ |
46 | - if (! $report) { |
|
46 | + if ( ! $report) { |
|
47 | 47 | \Errors::notFound('report'); |
48 | - } elseif (! $skipPermission && ! $this->userService->can($report->view_name, 'report')) { |
|
48 | + } elseif ( ! $skipPermission && ! $this->userService->can($report->view_name, 'report')) { |
|
49 | 49 | \Errors::noPermissions(); |
50 | 50 | } |
51 | 51 |
@@ -6,42 +6,42 @@ |
||
6 | 6 | |
7 | 7 | class ApiSkeletonServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Perform post-registration booting of services. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function boot() |
|
15 | - { |
|
16 | - $this->publishes([ |
|
17 | - __DIR__.'/Modules' => app_path('Modules'), |
|
18 | - __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | - __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | - __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | - __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | - __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | - __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | - __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | - __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | - __DIR__.'/../phpcs.xml' => base_path('/phpcs.xml'), |
|
27 | - ]); |
|
9 | + /** |
|
10 | + * Perform post-registration booting of services. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function boot() |
|
15 | + { |
|
16 | + $this->publishes([ |
|
17 | + __DIR__.'/Modules' => app_path('Modules'), |
|
18 | + __DIR__.'/Modules/Core/Resources/Assets' => base_path('public/doc/assets'), |
|
19 | + __DIR__.'/../lang' => base_path('resources/lang'), |
|
20 | + __DIR__.'/../files/Handler.php' => app_path('Exceptions/Handler.php'), |
|
21 | + __DIR__.'/../files/AuthServiceProvider.php' => app_path('Providers/AuthServiceProvider.php'), |
|
22 | + __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'), |
|
23 | + __DIR__.'/../files/Kernel.php' => app_path('Console/Kernel.php'), |
|
24 | + __DIR__.'/../files/HttpKernel.php' => app_path('Http/Kernel.php'), |
|
25 | + __DIR__.'/../files/channels.php' => base_path('routes/channels.php'), |
|
26 | + __DIR__.'/../phpcs.xml' => base_path('/phpcs.xml'), |
|
27 | + ]); |
|
28 | 28 | |
29 | - $this->publishes([ |
|
30 | - __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'), |
|
31 | - __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
32 | - ], 'config'); |
|
33 | - } |
|
29 | + $this->publishes([ |
|
30 | + __DIR__.'/../config/skeleton.php' => config_path('skeleton.php'), |
|
31 | + __DIR__.'/../files/auth.php' => config_path('auth.php'), |
|
32 | + ], 'config'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Register any package services. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - public function register() |
|
41 | - { |
|
42 | - $this->mergeConfigFrom( |
|
43 | - __DIR__.'/../config/skeleton.php', |
|
44 | - 'skeleton' |
|
45 | - ); |
|
46 | - } |
|
35 | + /** |
|
36 | + * Register any package services. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + public function register() |
|
41 | + { |
|
42 | + $this->mergeConfigFrom( |
|
43 | + __DIR__.'/../config/skeleton.php', |
|
44 | + 'skeleton' |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Password Reset Language Lines |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'password' => 'Passwords must be at least six characters and match the confirmation.', |
|
17 | - 'reset' => 'Your password has been reset!', |
|
18 | - 'sent' => 'We have e-mailed your password reset link!', |
|
19 | - 'token' => 'This password reset token is invalid.', |
|
20 | - 'user' => "We can't find a user with that e-mail address.", |
|
16 | + 'password' => 'Passwords must be at least six characters and match the confirmation.', |
|
17 | + 'reset' => 'Your password has been reset!', |
|
18 | + 'sent' => 'We have e-mailed your password reset link!', |
|
19 | + 'token' => 'This password reset token is invalid.', |
|
20 | + 'user' => "We can't find a user with that e-mail address.", |
|
21 | 21 | |
22 | 22 | ]; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Pagination Language Lines |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'previous' => '« Previous', |
|
17 | - 'next' => 'Next »', |
|
16 | + 'previous' => '« Previous', |
|
17 | + 'next' => 'Next »', |
|
18 | 18 | |
19 | 19 | ]; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Authentication Language Lines |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'failed' => 'These credentials do not match our records.', |
|
17 | - 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', |
|
16 | + 'failed' => 'These credentials do not match our records.', |
|
17 | + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', |
|
18 | 18 | |
19 | 19 | ]; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - /* |
|
5 | + /* |
|
6 | 6 | |-------------------------------------------------------------------------- |
7 | 7 | | Validation Language Lines |
8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,74 +13,74 @@ discard block |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | - 'accepted' => 'The :attribute must be accepted.', |
|
17 | - 'active_url' => 'The :attribute is not a valid URL.', |
|
18 | - 'after' => 'The :attribute must be a date after :date.', |
|
19 | - 'alpha' => 'The :attribute may only contain letters.', |
|
20 | - 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', |
|
21 | - 'alpha_num' => 'The :attribute may only contain letters and numbers.', |
|
22 | - 'array' => 'The :attribute must be an array.', |
|
23 | - 'before' => 'The :attribute must be a date before :date.', |
|
24 | - 'between' => [ |
|
25 | - 'numeric' => 'The :attribute must be between :min and :max.', |
|
26 | - 'file' => 'The :attribute must be between :min and :max kilobytes.', |
|
27 | - 'string' => 'The :attribute must be between :min and :max characters.', |
|
28 | - 'array' => 'The :attribute must have between :min and :max items.', |
|
29 | - ], |
|
30 | - 'boolean' => 'The :attribute field must be true or false.', |
|
31 | - 'confirmed' => 'The :attribute confirmation does not match.', |
|
32 | - 'date' => 'The :attribute is not a valid date.', |
|
33 | - 'date_format' => 'The :attribute does not match the format :format.', |
|
34 | - 'different' => 'The :attribute and :other must be different.', |
|
35 | - 'digits' => 'The :attribute must be :digits digits.', |
|
36 | - 'digits_between' => 'The :attribute must be between :min and :max digits.', |
|
37 | - 'distinct' => 'The :attribute field has a duplicate value.', |
|
38 | - 'email' => 'The :attribute must be a valid email address.', |
|
39 | - 'exists' => 'The selected :attribute is invalid.', |
|
40 | - 'filled' => 'The :attribute field is required.', |
|
41 | - 'image' => 'The :attribute must be an image.', |
|
42 | - 'in' => 'The selected :attribute is invalid.', |
|
43 | - 'in_array' => 'The :attribute field does not exist in :other.', |
|
44 | - 'integer' => 'The :attribute must be an integer.', |
|
45 | - 'ip' => 'The :attribute must be a valid IP address.', |
|
46 | - 'json' => 'The :attribute must be a valid JSON string.', |
|
47 | - 'max' => [ |
|
48 | - 'numeric' => 'The :attribute may not be greater than :max.', |
|
49 | - 'file' => 'The :attribute may not be greater than :max kilobytes.', |
|
50 | - 'string' => 'The :attribute may not be greater than :max characters.', |
|
51 | - 'array' => 'The :attribute may not have more than :max items.', |
|
52 | - ], |
|
53 | - 'mimes' => 'The :attribute must be a file of type: :values.', |
|
54 | - 'min' => [ |
|
55 | - 'numeric' => 'The :attribute must be at least :min.', |
|
56 | - 'file' => 'The :attribute must be at least :min kilobytes.', |
|
57 | - 'string' => 'The :attribute must be at least :min characters.', |
|
58 | - 'array' => 'The :attribute must have at least :min items.', |
|
59 | - ], |
|
60 | - 'not_in' => 'The selected :attribute is invalid.', |
|
61 | - 'numeric' => 'The :attribute must be a number.', |
|
62 | - 'present' => 'The :attribute field must be present.', |
|
63 | - 'regex' => 'The :attribute format is invalid.', |
|
64 | - 'required' => 'The :attribute field is required.', |
|
65 | - 'required_if' => 'The :attribute field is required when :other is :value.', |
|
66 | - 'required_unless' => 'The :attribute field is required unless :other is in :values.', |
|
67 | - 'required_with' => 'The :attribute field is required when :values is present.', |
|
68 | - 'required_with_all' => 'The :attribute field is required when :values is present.', |
|
69 | - 'required_without' => 'The :attribute field is required when :values is not present.', |
|
70 | - 'required_without_all' => 'The :attribute field is required when none of :values are present.', |
|
71 | - 'same' => 'The :attribute and :other must match.', |
|
72 | - 'size' => [ |
|
73 | - 'numeric' => 'The :attribute must be :size.', |
|
74 | - 'file' => 'The :attribute must be :size kilobytes.', |
|
75 | - 'string' => 'The :attribute must be :size characters.', |
|
76 | - 'array' => 'The :attribute must contain :size items.', |
|
77 | - ], |
|
78 | - 'string' => 'The :attribute must be a string.', |
|
79 | - 'timezone' => 'The :attribute must be a valid zone.', |
|
80 | - 'unique' => 'The :attribute has already been taken.', |
|
81 | - 'url' => 'The :attribute format is invalid.', |
|
16 | + 'accepted' => 'The :attribute must be accepted.', |
|
17 | + 'active_url' => 'The :attribute is not a valid URL.', |
|
18 | + 'after' => 'The :attribute must be a date after :date.', |
|
19 | + 'alpha' => 'The :attribute may only contain letters.', |
|
20 | + 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', |
|
21 | + 'alpha_num' => 'The :attribute may only contain letters and numbers.', |
|
22 | + 'array' => 'The :attribute must be an array.', |
|
23 | + 'before' => 'The :attribute must be a date before :date.', |
|
24 | + 'between' => [ |
|
25 | + 'numeric' => 'The :attribute must be between :min and :max.', |
|
26 | + 'file' => 'The :attribute must be between :min and :max kilobytes.', |
|
27 | + 'string' => 'The :attribute must be between :min and :max characters.', |
|
28 | + 'array' => 'The :attribute must have between :min and :max items.', |
|
29 | + ], |
|
30 | + 'boolean' => 'The :attribute field must be true or false.', |
|
31 | + 'confirmed' => 'The :attribute confirmation does not match.', |
|
32 | + 'date' => 'The :attribute is not a valid date.', |
|
33 | + 'date_format' => 'The :attribute does not match the format :format.', |
|
34 | + 'different' => 'The :attribute and :other must be different.', |
|
35 | + 'digits' => 'The :attribute must be :digits digits.', |
|
36 | + 'digits_between' => 'The :attribute must be between :min and :max digits.', |
|
37 | + 'distinct' => 'The :attribute field has a duplicate value.', |
|
38 | + 'email' => 'The :attribute must be a valid email address.', |
|
39 | + 'exists' => 'The selected :attribute is invalid.', |
|
40 | + 'filled' => 'The :attribute field is required.', |
|
41 | + 'image' => 'The :attribute must be an image.', |
|
42 | + 'in' => 'The selected :attribute is invalid.', |
|
43 | + 'in_array' => 'The :attribute field does not exist in :other.', |
|
44 | + 'integer' => 'The :attribute must be an integer.', |
|
45 | + 'ip' => 'The :attribute must be a valid IP address.', |
|
46 | + 'json' => 'The :attribute must be a valid JSON string.', |
|
47 | + 'max' => [ |
|
48 | + 'numeric' => 'The :attribute may not be greater than :max.', |
|
49 | + 'file' => 'The :attribute may not be greater than :max kilobytes.', |
|
50 | + 'string' => 'The :attribute may not be greater than :max characters.', |
|
51 | + 'array' => 'The :attribute may not have more than :max items.', |
|
52 | + ], |
|
53 | + 'mimes' => 'The :attribute must be a file of type: :values.', |
|
54 | + 'min' => [ |
|
55 | + 'numeric' => 'The :attribute must be at least :min.', |
|
56 | + 'file' => 'The :attribute must be at least :min kilobytes.', |
|
57 | + 'string' => 'The :attribute must be at least :min characters.', |
|
58 | + 'array' => 'The :attribute must have at least :min items.', |
|
59 | + ], |
|
60 | + 'not_in' => 'The selected :attribute is invalid.', |
|
61 | + 'numeric' => 'The :attribute must be a number.', |
|
62 | + 'present' => 'The :attribute field must be present.', |
|
63 | + 'regex' => 'The :attribute format is invalid.', |
|
64 | + 'required' => 'The :attribute field is required.', |
|
65 | + 'required_if' => 'The :attribute field is required when :other is :value.', |
|
66 | + 'required_unless' => 'The :attribute field is required unless :other is in :values.', |
|
67 | + 'required_with' => 'The :attribute field is required when :values is present.', |
|
68 | + 'required_with_all' => 'The :attribute field is required when :values is present.', |
|
69 | + 'required_without' => 'The :attribute field is required when :values is not present.', |
|
70 | + 'required_without_all' => 'The :attribute field is required when none of :values are present.', |
|
71 | + 'same' => 'The :attribute and :other must match.', |
|
72 | + 'size' => [ |
|
73 | + 'numeric' => 'The :attribute must be :size.', |
|
74 | + 'file' => 'The :attribute must be :size kilobytes.', |
|
75 | + 'string' => 'The :attribute must be :size characters.', |
|
76 | + 'array' => 'The :attribute must contain :size items.', |
|
77 | + ], |
|
78 | + 'string' => 'The :attribute must be a string.', |
|
79 | + 'timezone' => 'The :attribute must be a valid zone.', |
|
80 | + 'unique' => 'The :attribute has already been taken.', |
|
81 | + 'url' => 'The :attribute format is invalid.', |
|
82 | 82 | |
83 | - /* |
|
83 | + /* |
|
84 | 84 | |-------------------------------------------------------------------------- |
85 | 85 | | Custom Validation Language Lines |
86 | 86 | |-------------------------------------------------------------------------- |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | | |
92 | 92 | */ |
93 | 93 | |
94 | - 'custom' => [ |
|
95 | - 'attribute-name' => [ |
|
96 | - 'rule-name' => 'custom-message', |
|
97 | - ], |
|
98 | - ], |
|
94 | + 'custom' => [ |
|
95 | + 'attribute-name' => [ |
|
96 | + 'rule-name' => 'custom-message', |
|
97 | + ], |
|
98 | + ], |
|
99 | 99 | |
100 | - /* |
|
100 | + /* |
|
101 | 101 | |-------------------------------------------------------------------------- |
102 | 102 | | Custom Validation Attributes |
103 | 103 | |-------------------------------------------------------------------------- |
@@ -108,6 +108,6 @@ discard block |
||
108 | 108 | | |
109 | 109 | */ |
110 | 110 | |
111 | - 'attributes' => [], |
|
111 | + 'attributes' => [], |
|
112 | 112 | |
113 | 113 | ]; |