main
Artem-Darius Weber 2 years ago
parent 716af9ab04
commit 75627a1a19

@ -0,0 +1,52 @@
<?php
namespace App\Http\Controllers;
use App\Models\Game;
use Illuminate\Http\Request;
class GameController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$games = Game::orderBy('id', 'desc')->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)
{
//
}
}

@ -0,0 +1,57 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(int $id)
{
$user = User::findOrFail($id)->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)
{
//
}
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class DeveloperToGame extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Game extends Model
{
use HasFactory;
}

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class WishToGame extends Model
{
use HasFactory;
}

@ -28,6 +28,7 @@ class UserFactory extends Factory
'name' => $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,

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('games', function (Blueprint $table) {
$table->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');
}
};

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('developer_to_games', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id');
$table->bigInteger('game_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('developer_to_games');
}
};

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('wish_to_games', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id');
$table->bigInteger('game_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('wish_to_games');
}
};

@ -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);

@ -24,6 +24,7 @@ class AuthenticationTest extends TestCase
$response = $this->post('/login', [
'email' => $user->email,
'nickname' => 'nickname22',
'password' => 'password',
]);

Loading…
Cancel
Save