@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | | kernel and includes session state, CSRF protection, and more. |
| 12 | 12 | | |
| 13 | 13 | */ |
| 14 | -Route::group(['middleware' => ['web']], function () { |
|
| 14 | +Route::group([ 'middleware' => [ 'web' ] ], function() { |
|
| 15 | 15 | |
| 16 | 16 | Route::auth(); |
| 17 | 17 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /* |
| 29 | 29 | * Builders API for Android |
| 30 | 30 | */ |
| 31 | - Route::group(['prefix' => 'api'], function () { |
|
| 31 | + Route::group([ 'prefix' => 'api' ], function() { |
|
| 32 | 32 | |
| 33 | 33 | Route::post('/createaccount', [ |
| 34 | 34 | 'uses' => 'BuildersController@createAccount', |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | /* |
| 44 | 44 | * BackOffice |
| 45 | 45 | */ |
| 46 | - Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function () { |
|
| 46 | + Route::group([ 'prefix' => 'admin', 'middleware' => 'auth' ], function() { |
|
| 47 | 47 | |
| 48 | 48 | /* |
| 49 | 49 | * Cart Payment |
| 50 | 50 | */ |
| 51 | - Route::group(['prefix' => 'cart'], function () { |
|
| 51 | + Route::group([ 'prefix' => 'cart' ], function() { |
|
| 52 | 52 | /* |
| 53 | 53 | * Pages Recapitulatif |
| 54 | 54 | */ |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | /* |
| 104 | 104 | * COMMENTAIRES |
| 105 | 105 | */ |
| 106 | - Route::group(['prefix' => 'comments'], function () { |
|
| 107 | - Route::get('/index', ['uses' => 'CommentsController@index', 'as' => 'comments.index']); |
|
| 108 | - Route::post('{id}/update', ['uses' => 'CommentsController@update', 'as' => 'comments.update']); |
|
| 106 | + Route::group([ 'prefix' => 'comments' ], function() { |
|
| 107 | + Route::get('/index', [ 'uses' => 'CommentsController@index', 'as' => 'comments.index' ]); |
|
| 108 | + Route::post('{id}/update', [ 'uses' => 'CommentsController@update', 'as' => 'comments.update' ]); |
|
| 109 | 109 | |
| 110 | 110 | /* |
| 111 | 111 | * Action Like |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | /* |
| 121 | 121 | * CRUD de Movies |
| 122 | 122 | */ |
| 123 | - Route::group(['prefix' => 'movies'], function () { |
|
| 123 | + Route::group([ 'prefix' => 'movies' ], function() { |
|
| 124 | 124 | |
| 125 | 125 | /* |
| 126 | 126 | * Page index: liste des films |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | }); |
| 198 | 198 | |
| 199 | 199 | // CRUD de categories |
| 200 | - Route::group(['prefix' => 'categories'], function () { |
|
| 200 | + Route::group([ 'prefix' => 'categories' ], function() { |
|
| 201 | 201 | |
| 202 | 202 | Route::get('/index', [ |
| 203 | 203 | 'as' => 'categories_index', |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | }); |
| 245 | 245 | |
| 246 | 246 | // CRUD de actors |
| 247 | - Route::group(['prefix' => 'actors'], function () { |
|
| 247 | + Route::group([ 'prefix' => 'actors' ], function() { |
|
| 248 | 248 | |
| 249 | 249 | Route::get('/index', [ |
| 250 | 250 | 'as' => 'actors_index', |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | }); |
| 270 | 270 | |
| 271 | 271 | // CRUD de directors |
| 272 | - Route::group(['prefix' => 'directors'], function () { |
|
| 272 | + Route::group([ 'prefix' => 'directors' ], function() { |
|
| 273 | 273 | |
| 274 | 274 | Route::get('/index', [ |
| 275 | 275 | 'as' => 'directors_delete', |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | }); |
| 295 | 295 | |
| 296 | - Route::group(['prefix' => 'api'], function () { |
|
| 296 | + Route::group([ 'prefix' => 'api' ], function() { |
|
| 297 | 297 | |
| 298 | 298 | // mon retour en JSON de mes catégories |
| 299 | 299 | Route::get('/categories', [ |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | }); |
| 310 | 310 | |
| 311 | 311 | // CRUD de administrators |
| 312 | - Route::group(['prefix' => 'administrators', 'middleware' => 'authorisation'], function () { |
|
| 312 | + Route::group([ 'prefix' => 'administrators', 'middleware' => 'authorisation' ], function() { |
|
| 313 | 313 | |
| 314 | 314 | Route::get('/index', [ |
| 315 | 315 | 'as' => 'administrators_index', |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | /* |
| 358 | 358 | * Page FAQ |
| 359 | 359 | */ |
| 360 | - Route::get('/faq', function () { |
|
| 360 | + Route::get('/faq', function() { |
|
| 361 | 361 | |
| 362 | 362 | return view('Pages/faq'); |
| 363 | 363 | }); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | /* |
| 366 | 366 | * Page about |
| 367 | 367 | */ |
| 368 | - Route::get('/about', function () { |
|
| 368 | + Route::get('/about', function() { |
|
| 369 | 369 | |
| 370 | 370 | // retourne le nom de la vue |
| 371 | 371 | return view('Pages/about'); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | /* |
| 375 | 375 | * Pages concept |
| 376 | 376 | */ |
| 377 | - Route::get('/concept', function () { |
|
| 377 | + Route::get('/concept', function() { |
|
| 378 | 378 | |
| 379 | 379 | // retourne le nom de la vue |
| 380 | 380 | return view('Pages/concept'); |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | public function createAccount(Request $request) |
| 17 | 17 | { |
| 18 | 18 | $data = [ |
| 19 | - "name" => $request->name, |
|
| 20 | - "cp" => $request->cp, |
|
| 21 | - "phone" => $request->phone, |
|
| 22 | - "sexe" => $request->sexe, |
|
| 23 | - "news" => $request->news, |
|
| 19 | + "name" => $request->name, |
|
| 20 | + "cp" => $request->cp, |
|
| 21 | + "phone" => $request->phone, |
|
| 22 | + "sexe" => $request->sexe, |
|
| 23 | + "news" => $request->news, |
|
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | 26 | $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017'); |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | public function updateAccount(Request $request) |
| 66 | 66 | { |
| 67 | 67 | $data = [ |
| 68 | - "name" => $request->name, |
|
| 69 | - "cp" => $request->cp, |
|
| 70 | - "phone" => $request->phone, |
|
| 71 | - "sexe" => $request->sexe, |
|
| 72 | - "news" => $request->news, |
|
| 68 | + "name" => $request->name, |
|
| 69 | + "cp" => $request->cp, |
|
| 70 | + "phone" => $request->phone, |
|
| 71 | + "sexe" => $request->sexe, |
|
| 72 | + "news" => $request->news, |
|
| 73 | 73 | ]; |
| 74 | 74 | |
| 75 | 75 | $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017'); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | try{ |
| 35 | 35 | $collection->insertOne($stat); |
| 36 | - }catch (\Exception $e){ |
|
| 36 | + } catch (\Exception $e){ |
|
| 37 | 37 | return response()->json(['state' => false]); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | try{ |
| 84 | 84 | $collection->updateOne(["email" => $request->email], $stat); |
| 85 | - }catch (\Exception $e){ |
|
| 85 | + } catch (\Exception $e){ |
|
| 86 | 86 | return response()->json(['state' => false]); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | use App\Http\Models\Api; |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | 6 | use Illuminate\Support\Facades\Auth; |
| 7 | -use Illuminate\Support\Facades\Input; |
|
| 8 | 7 | |
| 9 | 8 | |
| 10 | 9 | /** |
@@ -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 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * @param array $user |
| 29 | 29 | */ |
| 30 | - public function __construct($user){ |
|
| 30 | + public function __construct($user) { |
|
| 31 | 31 | $this->user = $user; |
| 32 | 32 | $this->email = $user->email; |
| 33 | 33 | $this->password = $user->password; |