Initial GameLog setup
- Laravel 11 + Breeze (dark mode) + Tailwind + Alpine.js - Migrations: games, genres, platforms, companies, pivots, user_games, user_lists, reviews, follows, activities - Models: Game, Genre, Platform, Company, UserGame, UserList, Review, ReviewVote, Activity, User (with gamelog fields) - IgdbService: OAuth2 token management, search, game fetch, popular/new releases, genre filter, cover/screenshot URL helpers - IGDB credentials in config/services.php (from .env)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedSmallInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->string('connection');
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
|
||||
$table->index(['connection', 'queue', 'failed_at']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('companies', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('igdb_id')->unique()->nullable();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('companies'); }
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('game_company', function (Blueprint $table) {
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('company_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('role')->default('developer'); // developer|publisher
|
||||
$table->primary(['game_id', 'company_id', 'role']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('game_company'); }
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('game_genre', function (Blueprint $table) {
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('genre_id')->constrained()->cascadeOnDelete();
|
||||
$table->primary(['game_id', 'genre_id']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('game_genre'); }
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('game_platform', function (Blueprint $table) {
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('platform_id')->constrained()->cascadeOnDelete();
|
||||
$table->primary(['game_id', 'platform_id']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('game_platform'); }
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('game_screenshots', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('url');
|
||||
$table->string('thumb_url')->nullable();
|
||||
$table->unsignedTinyInteger('order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('game_screenshots'); }
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('games', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('igdb_id')->unique()->nullable();
|
||||
$table->string('slug')->unique();
|
||||
$table->string('title');
|
||||
$table->text('summary')->nullable();
|
||||
$table->string('cover_url')->nullable();
|
||||
$table->string('cover_thumb_url')->nullable();
|
||||
$table->date('release_date')->nullable();
|
||||
$table->string('release_year', 4)->nullable()->index();
|
||||
$table->decimal('rating_avg', 4, 2)->nullable()->default(null);
|
||||
$table->unsignedInteger('rating_count')->default(0);
|
||||
$table->unsignedInteger('review_count')->default(0);
|
||||
$table->unsignedInteger('library_count')->default(0);
|
||||
$table->string('status')->default('published'); // published|pending|hidden
|
||||
$table->timestamps();
|
||||
$table->index(['rating_avg', 'rating_count']);
|
||||
$table->index('release_year');
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('games'); }
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('genres', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('igdb_id')->unique()->nullable();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('genres'); }
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('platforms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('igdb_id')->unique()->nullable();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('abbreviation')->nullable();
|
||||
$table->string('icon')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('platforms'); }
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('username')->unique()->nullable()->after('name');
|
||||
$table->string('avatar')->nullable()->after('email');
|
||||
$table->text('bio')->nullable()->after('avatar');
|
||||
$table->string('location')->nullable()->after('bio');
|
||||
$table->string('website')->nullable()->after('location');
|
||||
$table->boolean('is_private')->default(false)->after('website');
|
||||
$table->boolean('is_admin')->default(false)->after('is_private');
|
||||
$table->timestamp('last_active_at')->nullable()->after('is_admin');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['username','avatar','bio','location','website','is_private','is_admin','last_active_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('activities', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('type'); // rated_game|added_game|completed_game|wrote_review|created_list
|
||||
$table->nullableMorphs('subject');
|
||||
$table->json('data')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index(['user_id', 'created_at']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('activities'); }
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('follows', function (Blueprint $table) {
|
||||
$table->foreignId('follower_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignId('following_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->primary(['follower_id', 'following_id']);
|
||||
$table->index('following_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('follows'); }
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('review_votes', function (Blueprint $table) {
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('review_id')->constrained()->cascadeOnDelete();
|
||||
$table->boolean('is_helpful');
|
||||
$table->primary(['user_id', 'review_id']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('review_votes'); }
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('reviews', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('rating')->nullable(); // 1-10
|
||||
$table->text('body');
|
||||
$table->boolean('has_spoilers')->default(false);
|
||||
$table->unsignedInteger('helpful_count')->default(0);
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'game_id']);
|
||||
$table->index(['game_id', 'helpful_count']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('reviews'); }
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('user_games', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('status'); // playing|played|want_to_play|on_hold|dropped
|
||||
$table->unsignedTinyInteger('rating')->nullable(); // 1-10
|
||||
$table->date('start_date')->nullable();
|
||||
$table->date('finish_date')->nullable();
|
||||
$table->unsignedSmallInteger('hours_played')->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->boolean('is_private')->default(false);
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'game_id']);
|
||||
$table->index(['user_id', 'status']);
|
||||
$table->index('game_id');
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('user_games'); }
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('user_list_games', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_list_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedSmallInteger('order')->default(0);
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['user_list_id', 'game_id']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('user_list_games'); }
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('user_lists', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->string('slug');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('is_public')->default(true);
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'slug']);
|
||||
$table->index('user_id');
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('user_lists'); }
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user