@@ -67,8 +67,8 @@ |
||
67 | 67 | protected function unauthenticated($request, AuthenticationException $exception) |
68 | 68 | { |
69 | 69 | if ($request->expectsJson()) { |
70 | - return response()->json(['errors' => [ |
|
71 | - [Error::STATUS => 401, Error::TITLE => 'Authentication error', Error::DETAIL => 'Unauthenticated']] |
|
70 | + return response()->json([ 'errors' => [ |
|
71 | + [ Error::STATUS => 401, Error::TITLE => 'Authentication error', Error::DETAIL => 'Unauthenticated' ] ] |
|
72 | 72 | ], 401); |
73 | 73 | } |
74 | 74 |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | protected function create(array $data) |
81 | 81 | { |
82 | 82 | $user = User::create([ |
83 | - 'name' => $data['name'], |
|
84 | - 'email' => $data['email'], |
|
85 | - 'password' => bcrypt($data['password']) |
|
83 | + 'name' => $data[ 'name' ], |
|
84 | + 'email' => $data[ 'email' ], |
|
85 | + 'password' => bcrypt($data[ 'password' ]) |
|
86 | 86 | ]); |
87 | 87 | |
88 | 88 | return $user; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | return $this->sendLoginResponse($token, $user); |
168 | 168 | } |
169 | 169 | |
170 | - $error = ['activation_hash' => ['Wrong activation hash']]; |
|
170 | + $error = [ 'activation_hash' => [ 'Wrong activation hash' ] ]; |
|
171 | 171 | |
172 | 172 | return $this->sendFailedResponse($error, self::HTTP_CODE_BAD_REQUEST); |
173 | 173 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | return $this->sendSuccessResponse(); |
55 | 55 | } |
56 | 56 | |
57 | - $errors = ['password' => ['Wrong credentials']]; |
|
57 | + $errors = [ 'password' => [ 'Wrong credentials' ] ]; |
|
58 | 58 | |
59 | 59 | return $this->sendFailedResponse($errors, self::HTTP_CODE_BAD_REQUEST); |
60 | 60 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $response = $this->broker()->reset( |
63 | 63 | $this->credentials($request), |
64 | - function ($user, $password) { |
|
64 | + function($user, $password) { |
|
65 | 65 | $this->resetPassword($user, $password); |
66 | 66 | } |
67 | 67 | ); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $response == Password::PASSWORD_RESET |
71 | 71 | ? $this->sendSuccessResponse() |
72 | 72 | : $this->sendFailedResponse( |
73 | - ['token' => 'Your reset link has expired. Please try to resend it again.'], |
|
73 | + [ 'token' => 'Your reset link has expired. Please try to resend it again.' ], |
|
74 | 74 | self::HTTP_CODE_BAD_REQUEST |
75 | 75 | ); |
76 | 76 | } |
@@ -17,66 +17,66 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function sendFailedResponse(array $errors, int $statusCode) |
19 | 19 | { |
20 | - $errorsJson = []; |
|
21 | - if (!empty($errors['email'])) { |
|
20 | + $errorsJson = [ ]; |
|
21 | + if (!empty($errors[ 'email' ])) { |
|
22 | 22 | $emailError = [ |
23 | 23 | 'status' => $statusCode, |
24 | 24 | 'title' => 'Email error', |
25 | - 'detail' => $errors['email'][0] |
|
25 | + 'detail' => $errors[ 'email' ][ 0 ] |
|
26 | 26 | ]; |
27 | 27 | array_push($errorsJson, $emailError); |
28 | 28 | } |
29 | 29 | |
30 | - if (!empty($errors['password'])) { |
|
30 | + if (!empty($errors[ 'password' ])) { |
|
31 | 31 | $passwordError = [ |
32 | 32 | 'status' => $statusCode, |
33 | 33 | 'title' => 'Password error', |
34 | - 'detail' => $errors['password'][0] |
|
34 | + 'detail' => $errors[ 'password' ][ 0 ] |
|
35 | 35 | ]; |
36 | 36 | array_push($errorsJson, $passwordError); |
37 | 37 | } |
38 | 38 | |
39 | - if (!empty($errors['password_confirmation'])) { |
|
39 | + if (!empty($errors[ 'password_confirmation' ])) { |
|
40 | 40 | $passwordConfirmationError = [ |
41 | 41 | 'status' => $statusCode, |
42 | 42 | 'title' => 'Password error', |
43 | - 'detail' => $errors['password_confirmation'][0] |
|
43 | + 'detail' => $errors[ 'password_confirmation' ][ 0 ] |
|
44 | 44 | ]; |
45 | 45 | array_push($errorsJson, $passwordConfirmationError); |
46 | 46 | } |
47 | 47 | |
48 | - if (!empty($errors['name'])) { |
|
48 | + if (!empty($errors[ 'name' ])) { |
|
49 | 49 | $nameError = [ |
50 | 50 | 'status' => $statusCode, |
51 | 51 | 'title' => 'Name error', |
52 | - 'detail' => $errors['name'][0] |
|
52 | + 'detail' => $errors[ 'name' ][ 0 ] |
|
53 | 53 | ]; |
54 | 54 | array_push($errorsJson, $nameError); |
55 | 55 | } |
56 | 56 | |
57 | - if (!empty($errors['token'])) { |
|
57 | + if (!empty($errors[ 'token' ])) { |
|
58 | 58 | $tokenError = [ |
59 | 59 | 'status' => $statusCode, |
60 | 60 | 'title' => 'Token error', |
61 | - 'detail' => $errors['token'] |
|
61 | + 'detail' => $errors[ 'token' ] |
|
62 | 62 | ]; |
63 | 63 | array_push($errorsJson, $tokenError); |
64 | 64 | } |
65 | 65 | |
66 | - if (!empty($errors['token'])) { |
|
66 | + if (!empty($errors[ 'token' ])) { |
|
67 | 67 | $tokenError = [ |
68 | 68 | 'status' => $statusCode, |
69 | 69 | 'title' => 'Token error', |
70 | - 'detail' => $errors['token'] |
|
70 | + 'detail' => $errors[ 'token' ] |
|
71 | 71 | ]; |
72 | 72 | array_push($errorsJson, $tokenError); |
73 | 73 | } |
74 | 74 | |
75 | - if (!empty($errors['activation_hash'])) { |
|
75 | + if (!empty($errors[ 'activation_hash' ])) { |
|
76 | 76 | $activationHashError = [ |
77 | 77 | 'status' => $statusCode, |
78 | 78 | 'title' => 'Activation hash error', |
79 | - 'detail' => $errors['activation_hash'][0] |
|
79 | + 'detail' => $errors[ 'activation_hash' ][ 0 ] |
|
80 | 80 | ]; |
81 | 81 | array_push($errorsJson, $activationHashError); |
82 | 82 | } |
@@ -96,6 +96,6 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function sendSuccessResponse() |
98 | 98 | { |
99 | - return response()->json([], self::HTTP_CODE_OK); |
|
99 | + return response()->json([ ], self::HTTP_CODE_OK); |
|
100 | 100 | } |
101 | 101 | } |
@@ -104,8 +104,8 @@ |
||
104 | 104 | { |
105 | 105 | return Mail::send( |
106 | 106 | $this->activationEmailTemplate, |
107 | - ['hash' => $hash], |
|
108 | - function ($message) use ($user) { |
|
107 | + [ 'hash' => $hash ], |
|
108 | + function($message) use ($user) { |
|
109 | 109 | $message->to($user->email, $user->usename)->subject('Laravel api boilerplate'); |
110 | 110 | } |
111 | 111 | ); |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | Mail::send( |
35 | 35 | $this->remindPasswordEmailTemplate, |
36 | - ['hash' => $token, 'email' => $email], |
|
37 | - function ($message) use ($user) { |
|
36 | + [ 'hash' => $token, 'email' => $email ], |
|
37 | + function($message) use ($user) { |
|
38 | 38 | $message->to($user->email, $user->usename)->subject('Laravel api boilerplate'); |
39 | 39 | } |
40 | 40 | ); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $user = Auth::user(); |
56 | 56 | |
57 | 57 | if (Hash::check($request->get('current_password'), $user->password)) { |
58 | - $user->password = Hash::make($request['password']); |
|
58 | + $user->password = Hash::make($request[ 'password' ]); |
|
59 | 59 | $user->save(); |
60 | 60 | |
61 | 61 | return true; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function __construct() |
42 | 42 | { |
43 | - $this->middleware('guest', ['except' => 'logout']); |
|
43 | + $this->middleware('guest', [ 'except' => 'logout' ]); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | return $this->sendLoginResponse($request, $token); |
89 | 89 | } else { |
90 | 90 | $error = [ |
91 | - 'source' => ['email' => $request->get('email')], |
|
92 | - 'email' => ['Email not verified'] |
|
91 | + 'source' => [ 'email' => $request->get('email') ], |
|
92 | + 'email' => [ 'Email not verified' ] |
|
93 | 93 | ]; |
94 | 94 | return $this->sendFailedResponse($error, 403); |
95 | 95 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->incrementLoginAttempts($request); |
100 | 100 | |
101 | 101 | $error = [ |
102 | - 'email' => ['Invalid credentials. Please check login/password and try again'] |
|
102 | + 'email' => [ 'Invalid credentials. Please check login/password and try again' ] |
|
103 | 103 | ]; |
104 | 104 | |
105 | 105 | return $this->sendFailedResponse($error, 401); |
@@ -130,7 +130,7 @@ |
||
130 | 130 | { |
131 | 131 | foreach ($this->migrations as $key => $value) { |
132 | 132 | $mask = database_path('migrations/*' . $value); |
133 | - array_map( "unlink", glob( $mask ) ); |
|
133 | + array_map("unlink", glob($mask)); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 |