@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | 'created' => new \DateTime("now"), |
| 35 | 35 | ]; |
| 36 | 36 | |
| 37 | - try{ |
|
| 37 | + try { |
|
| 38 | 38 | $collection->insertOne($stat); |
| 39 | - }catch (\Exception $e){ |
|
| 40 | - return response()->json(['state' => false]); |
|
| 39 | + } catch (\Exception $e) { |
|
| 40 | + return response()->json([ 'state' => false ]); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $data["email"] = $request->email; |
|
| 44 | - return response()->json(['data' => $data, 'state' => true]); |
|
| 43 | + $data[ "email" ] = $request->email; |
|
| 44 | + return response()->json([ 'data' => $data, 'state' => true ]); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -57,26 +57,26 @@ discard block |
||
| 57 | 57 | $collection = new \MongoDB\Collection($manager, 'builders', 'account'); |
| 58 | 58 | |
| 59 | 59 | |
| 60 | - if ($collection->count(["email" => $email]) == 0) { |
|
| 61 | - return response()->json(['data' => "User doesn't exist", 'state' => false]); |
|
| 60 | + if ($collection->count([ "email" => $email ]) == 0) { |
|
| 61 | + return response()->json([ 'data' => "User doesn't exist", 'state' => false ]); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $user = $collection->findOne(["email" => $email])->bsonSerialize(); |
|
| 64 | + $user = $collection->findOne([ "email" => $email ])->bsonSerialize(); |
|
| 65 | 65 | |
| 66 | - if(password_verify($password, $user->password) == false){ |
|
| 67 | - return response()->json(['data' => "Bad email or password", 'state' => false]); |
|
| 66 | + if (password_verify($password, $user->password) == false) { |
|
| 67 | + return response()->json([ 'data' => "Bad email or password", 'state' => false ]); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $api = new Api($user); |
| 71 | 71 | Auth::login($api); |
| 72 | 72 | |
| 73 | - return response()->json(['data' => $user, 'state' => true]); |
|
| 73 | + return response()->json([ 'data' => $user, 'state' => true ]); |
|
| 74 | 74 | |
| 75 | 75 | } else { |
| 76 | - return response()->json(['data' => "Invalid parameters", 'state' => false]); |
|
| 76 | + return response()->json([ 'data' => "Invalid parameters", 'state' => false ]); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - return response()->json(['data' => "Bad credentials", 'state' => false]); |
|
| 79 | + return response()->json([ 'data' => "Bad credentials", 'state' => false ]); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | auth()->guard('api')->logout(); |
| 90 | 90 | |
| 91 | - return response()->json(['state' => true]); |
|
| 91 | + return response()->json([ 'state' => true ]); |
|
| 92 | 92 | |
| 93 | 93 | } else { |
| 94 | 94 | |
| 95 | - return response()->json(['state' => false]); |
|
| 95 | + return response()->json([ 'state' => false ]); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | } |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | if ($auth->attempt($credentials) && auth()->guard('user')->check()) { |
| 117 | 117 | |
| 118 | - return response()->json(['data' => auth()->guard('user')->user()->toArray(), 'state' => true]); |
|
| 118 | + return response()->json([ 'data' => auth()->guard('user')->user()->toArray(), 'state' => true ]); |
|
| 119 | 119 | } else { |
| 120 | - return response()->json(['data' => "Bad email or password", 'state' => false]); |
|
| 120 | + return response()->json([ 'data' => "Bad email or password", 'state' => false ]); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | } else { |
| 124 | - return response()->json(['data' => "Invalid parameters", 'state' => false]); |
|
| 124 | + return response()->json([ 'data' => "Invalid parameters", 'state' => false ]); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - return response()->json(['data' => "Bad credentials", 'state' => false]); |
|
| 127 | + return response()->json([ 'data' => "Bad credentials", 'state' => false ]); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -137,9 +137,9 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $result = $collection->find()->toArray(); |
| 139 | 139 | |
| 140 | - $tab = []; |
|
| 141 | - foreach($result as $one){ |
|
| 142 | - $tab[] = $one->bsonSerialize(); |
|
| 140 | + $tab = [ ]; |
|
| 141 | + foreach ($result as $one) { |
|
| 142 | + $tab[ ] = $one->bsonSerialize(); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | return response()->json($tab); |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | 'created' => new \DateTime("now"), |
| 167 | 167 | ]; |
| 168 | 168 | |
| 169 | - try{ |
|
| 170 | - $collection->updateOne(["email" => $request->email], $stat); |
|
| 171 | - }catch (\Exception $e){ |
|
| 172 | - return response()->json(['state' => false]); |
|
| 169 | + try { |
|
| 170 | + $collection->updateOne([ "email" => $request->email ], $stat); |
|
| 171 | + } catch (\Exception $e) { |
|
| 172 | + return response()->json([ 'state' => false ]); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $data["email"] = $request->email; |
|
| 176 | - return response()->json(['data' => $data, 'state' => true]); |
|
| 175 | + $data[ "email" ] = $request->email; |
|
| 176 | + return response()->json([ 'data' => $data, 'state' => true ]); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | } |