diff --git a/app/Http/Controllers/GameController.php b/app/Http/Controllers/GameController.php new file mode 100644 index 0000000..2967420 --- /dev/null +++ b/app/Http/Controllers/GameController.php @@ -0,0 +1,52 @@ +get()->toArray(); + return response()->json(['games' => $games], 200); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { +// $game = Game::created($request); +// return response()->json(['ressult' => $game->toArray()], 200); + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + $game = Game::findOrFail($id)->toArray(); + return response()->json(['game' => $game], 200); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php new file mode 100644 index 0000000..de9c8ee --- /dev/null +++ b/app/Http/Controllers/UserController.php @@ -0,0 +1,57 @@ +toArray(); + return response()->json(['user' => $user], 200); + } + + public function isLoginFilsCorrect(Request $req) { + $user = User::where('email', $req->email)->where('password', Hash::make($req->password))->find(); + if ($user) return "yes"; + return "no"; + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/DeveloperToGame.php b/app/Models/DeveloperToGame.php new file mode 100644 index 0000000..cf9730a --- /dev/null +++ b/app/Models/DeveloperToGame.php @@ -0,0 +1,11 @@ + $this->faker->name(), 'email' => $this->faker->unique()->safeEmail(), 'email_verified_at' => now(), + 'nickname' => Str::random(10), 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'two_factor_secret' => null, 'two_factor_recovery_codes' => null, diff --git a/database/migrations/2023_05_11_123938_create_games_table.php b/database/migrations/2023_05_11_123938_create_games_table.php new file mode 100644 index 0000000..233c0ab --- /dev/null +++ b/database/migrations/2023_05_11_123938_create_games_table.php @@ -0,0 +1,35 @@ +id(); + $table->string('name')->unique(); + $table->bigInteger('developer_id')->nullable(); + $table->text('system_req')->nullable(); + $table->text('desc')->nullable(); + $table->integer('price'); + $table->string('courecy')->default("RU-ru"); + $table->float('discount')->default(0.0); + $table->date('release')->default(now()); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('games'); + } +}; diff --git a/database/migrations/2023_05_11_124931_create_developer_to_games_table.php b/database/migrations/2023_05_11_124931_create_developer_to_games_table.php new file mode 100644 index 0000000..f597a8d --- /dev/null +++ b/database/migrations/2023_05_11_124931_create_developer_to_games_table.php @@ -0,0 +1,29 @@ +id(); + $table->bigInteger('user_id'); + $table->bigInteger('game_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('developer_to_games'); + } +}; diff --git a/database/migrations/2023_05_11_130336_create_wish_to_games_table.php b/database/migrations/2023_05_11_130336_create_wish_to_games_table.php new file mode 100644 index 0000000..604892a --- /dev/null +++ b/database/migrations/2023_05_11_130336_create_wish_to_games_table.php @@ -0,0 +1,29 @@ +id(); + $table->bigInteger('user_id'); + $table->bigInteger('game_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('wish_to_games'); + } +}; diff --git a/routes/api.php b/routes/api.php index 889937e..bb6a8d6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -17,3 +17,6 @@ use Illuminate\Support\Facades\Route; Route::middleware('auth:sanctum')->get('/user', function (Request $request) { return $request->user(); }); + +Route::middleware('auth:sanctum')->apiResource('/game', \App\Http\Controllers\GameController::class); + diff --git a/tests/Feature/AuthenticationTest.php b/tests/Feature/AuthenticationTest.php index 7623fe9..052abe7 100644 --- a/tests/Feature/AuthenticationTest.php +++ b/tests/Feature/AuthenticationTest.php @@ -24,6 +24,7 @@ class AuthenticationTest extends TestCase $response = $this->post('/login', [ 'email' => $user->email, + 'nickname' => 'nickname22', 'password' => 'password', ]);