From 71dd328431d55f818cefffd8b96634a6fe19793a Mon Sep 17 00:00:00 2001 From: DoarMihai Date: Fri, 13 Jun 2025 23:06:13 +0300 Subject: [PATCH] some progress --- app/Http/Controllers/GameController.php | 4 +- app/Http/Controllers/GameListController.php | 10 +- app/Http/Controllers/HomeController.php | 13 ++ .../CreateDefaultUsersListListener.php | 39 +++++ app/Models/GameList.php | 4 +- app/Models/Rating.php | 3 +- app/Models/Review.php | 1 + app/Models/Wishlist.php | 25 +++ app/Policies/GameListPolicy.php | 6 +- app/Providers/AppServiceProvider.php | 4 + composer.json | 1 + composer.lock | 157 +++++++++++++++++- ..._10_113701_add_ratings_platform_column.php | 28 ++++ ..._10_113727_add_reviews_platform_column.php | 28 ++++ ...25_05_10_122834_create_wishlists_table.php | 31 ++++ resources/css/app.css | 16 ++ resources/views/games/index.blade.php | 71 ++++---- resources/views/games/show.blade.php | 20 ++- resources/views/index.blade.php | 51 ++++++ resources/views/landing.blade.php | 12 +- resources/views/layouts/app.blade.php | 27 ++- resources/views/layouts/navigation.blade.php | 66 ++++---- resources/views/lists/index.blade.php | 92 +++++----- routes/web.php | 9 +- storage/debugbar/.gitignore | 2 + 25 files changed, 594 insertions(+), 126 deletions(-) create mode 100644 app/Http/Controllers/HomeController.php create mode 100644 app/Listeners/CreateDefaultUsersListListener.php create mode 100644 app/Models/Wishlist.php create mode 100644 database/migrations/2025_05_10_113701_add_ratings_platform_column.php create mode 100644 database/migrations/2025_05_10_113727_add_reviews_platform_column.php create mode 100644 database/migrations/2025_05_10_122834_create_wishlists_table.php create mode 100644 resources/views/index.blade.php create mode 100644 storage/debugbar/.gitignore diff --git a/app/Http/Controllers/GameController.php b/app/Http/Controllers/GameController.php index 7ab2087..c8d0536 100644 --- a/app/Http/Controllers/GameController.php +++ b/app/Http/Controllers/GameController.php @@ -81,12 +81,12 @@ class GameController extends Controller } } - $games = $query->paginate(12)->withQueryString(); + $games = $query->paginate(36)->withQueryString(); // Get data for filter dropdowns $platforms = \App\Models\Platform::orderBy('name')->get(); $genres = \App\Models\Genre::orderBy('name')->get(); - + // Get unique years from games $years = Game::selectRaw('YEAR(first_release_date) as year') ->whereNotNull('first_release_date') diff --git a/app/Http/Controllers/GameListController.php b/app/Http/Controllers/GameListController.php index 875fc44..e4a4435 100644 --- a/app/Http/Controllers/GameListController.php +++ b/app/Http/Controllers/GameListController.php @@ -6,12 +6,13 @@ use App\Models\Game; use App\Models\GameList; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Gate; class GameListController extends Controller { public function __construct() { - $this->middleware('auth'); + //$this->middleware('auth'); } /** @@ -54,8 +55,9 @@ class GameListController extends Controller */ public function show(GameList $list) { - $this->authorize('view', $list); - + //$this->authorize('view', $list); + Gate::authorize('view', $list); + $games = $list->games()->paginate(12); return view('lists.show', compact('list', 'games')); } @@ -106,7 +108,7 @@ class GameListController extends Controller public function addGame(Request $request, GameList $list) { - $this->authorize('update', $list); + Gate::authorize('update', $list); $request->validate([ 'game_id' => 'required|exists:games,id' diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..f310118 --- /dev/null +++ b/app/Http/Controllers/HomeController.php @@ -0,0 +1,13 @@ + $event->user->id, + 'name' => $listName, + ]); + } + } +} diff --git a/app/Models/GameList.php b/app/Models/GameList.php index d626083..aa60d14 100644 --- a/app/Models/GameList.php +++ b/app/Models/GameList.php @@ -40,6 +40,8 @@ class GameList extends Model public function games(): BelongsToMany { - return $this->belongsToMany(Game::class)->withTimestamps(); + return $this->belongsToMany(Game::class) + ->with(['platforms']) + ->withTimestamps(); } } diff --git a/app/Models/Rating.php b/app/Models/Rating.php index 80f411a..597a834 100644 --- a/app/Models/Rating.php +++ b/app/Models/Rating.php @@ -14,6 +14,7 @@ class Rating extends Model 'user_id', 'game_id', 'rating', + 'platform', ]; protected $casts = [ @@ -29,4 +30,4 @@ class Rating extends Model { return $this->belongsTo(Game::class); } -} \ No newline at end of file +} diff --git a/app/Models/Review.php b/app/Models/Review.php index 5f8e1b8..3c088f0 100644 --- a/app/Models/Review.php +++ b/app/Models/Review.php @@ -16,6 +16,7 @@ class Review extends Model 'content', 'recommended', 'rating', + 'platform', ]; protected $casts = [ diff --git a/app/Models/Wishlist.php b/app/Models/Wishlist.php new file mode 100644 index 0000000..de6429c --- /dev/null +++ b/app/Models/Wishlist.php @@ -0,0 +1,25 @@ +id === $list->user_id; + //return $user->id === $list->user_id; + return true; } /** diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b6e0fe6..228b748 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,7 +2,10 @@ namespace App\Providers; +use App\Models\GameList; +use App\Policies\GameListPolicy; use Illuminate\Pagination\Paginator; +use Illuminate\Support\Facades\Gate; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -21,5 +24,6 @@ class AppServiceProvider extends ServiceProvider public function boot(): void { Paginator::useBootstrap(); + Gate::policy(GameList::class, GameListPolicy::class); } } diff --git a/composer.json b/composer.json index 7a6962a..006146c 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "marcreichel/igdb-laravel": "^5.3" }, "require-dev": { + "barryvdh/laravel-debugbar": "^3.15", "fakerphp/faker": "^1.23", "laravel/breeze": "^2.3", "laravel/pail": "^1.2.2", diff --git a/composer.lock b/composer.lock index c0771a1..7399ce8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7b46d7d171bc99166a5acfa33ef476cb", + "content-hash": "0814da2c93b6041a9dc275ff1eda9043", "packages": [ { "name": "brick/math", @@ -5894,6 +5894,91 @@ } ], "packages-dev": [ + { + "name": "barryvdh/laravel-debugbar", + "version": "v3.15.4", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-debugbar.git", + "reference": "c0667ea91f7185f1e074402c5788195e96bf8106" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/c0667ea91f7185f1e074402c5788195e96bf8106", + "reference": "c0667ea91f7185f1e074402c5788195e96bf8106", + "shasum": "" + }, + "require": { + "illuminate/routing": "^9|^10|^11|^12", + "illuminate/session": "^9|^10|^11|^12", + "illuminate/support": "^9|^10|^11|^12", + "php": "^8.1", + "php-debugbar/php-debugbar": "~2.1.1", + "symfony/finder": "^6|^7" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "orchestra/testbench-dusk": "^7|^8|^9|^10", + "phpunit/phpunit": "^9.5.10|^10|^11", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" + }, + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ] + }, + "branch-alias": { + "dev-master": "3.15-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "dev", + "laravel", + "profiler", + "webprofiler" + ], + "support": { + "issues": "https://github.com/barryvdh/laravel-debugbar/issues", + "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.15.4" + }, + "funding": [ + { + "url": "https://fruitcake.nl", + "type": "custom" + }, + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], + "time": "2025-04-16T06:32:06+00:00" + }, { "name": "fakerphp/faker", "version": "v1.24.1", @@ -6707,6 +6792,76 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-debugbar/php-debugbar", + "version": "v2.1.6", + "source": { + "type": "git", + "url": "https://github.com/php-debugbar/php-debugbar.git", + "reference": "16fa68da5617220594aa5e33fa9de415f94784a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/16fa68da5617220594aa5e33fa9de415f94784a0", + "reference": "16fa68da5617220594aa5e33fa9de415f94784a0", + "shasum": "" + }, + "require": { + "php": "^8", + "psr/log": "^1|^2|^3", + "symfony/var-dumper": "^4|^5|^6|^7" + }, + "require-dev": { + "dbrekelmans/bdi": "^1", + "phpunit/phpunit": "^8|^9", + "symfony/panther": "^1|^2.1", + "twig/twig": "^1.38|^2.7|^3.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/php-debugbar/php-debugbar", + "keywords": [ + "debug", + "debug bar", + "debugbar", + "dev" + ], + "support": { + "issues": "https://github.com/php-debugbar/php-debugbar/issues", + "source": "https://github.com/php-debugbar/php-debugbar/tree/v2.1.6" + }, + "time": "2025-02-21T17:47:03+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "11.0.9", diff --git a/database/migrations/2025_05_10_113701_add_ratings_platform_column.php b/database/migrations/2025_05_10_113701_add_ratings_platform_column.php new file mode 100644 index 0000000..8dbdd0b --- /dev/null +++ b/database/migrations/2025_05_10_113701_add_ratings_platform_column.php @@ -0,0 +1,28 @@ +string('platform'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('ratings', function (Blueprint $table) { + $table->dropColumn('platform'); + }); + } +}; diff --git a/database/migrations/2025_05_10_113727_add_reviews_platform_column.php b/database/migrations/2025_05_10_113727_add_reviews_platform_column.php new file mode 100644 index 0000000..c384662 --- /dev/null +++ b/database/migrations/2025_05_10_113727_add_reviews_platform_column.php @@ -0,0 +1,28 @@ +string('platform'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('reviews', function (Blueprint $table) { + $table->dropColumn('platform'); + }); + } +}; diff --git a/database/migrations/2025_05_10_122834_create_wishlists_table.php b/database/migrations/2025_05_10_122834_create_wishlists_table.php new file mode 100644 index 0000000..d4eb1d9 --- /dev/null +++ b/database/migrations/2025_05_10_122834_create_wishlists_table.php @@ -0,0 +1,31 @@ +id(); + $table->bigInteger('user_id'); + $table->string('name'); + $table->text('description')->nullable(); + $table->enum('visibility', ['public', 'private', 'friends_only'])->default('public'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('wishlists'); + } +}; diff --git a/resources/css/app.css b/resources/css/app.css index 47b74c5..45ae95c 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -228,3 +228,19 @@ body { .dropdown-divider { border-top: 1px solid #334155; } + +.cover-container{ + position:relative; +} + +.cover-container a:hover+.game-info-cover{ + display: flex; +} +.cover-container .game-info-cover{ + border: 1px solid #000; + margin-left: 10px; + position: absolute; top: 0; left: 0; + width: 100%; height: 100%; + color: #fff; background: rgba(0, 0, 0, 0.7); + display: none; justify-content: center; align-items: center; +} diff --git a/resources/views/games/index.blade.php b/resources/views/games/index.blade.php index 335d3d0..97de362 100644 --- a/resources/views/games/index.blade.php +++ b/resources/views/games/index.blade.php @@ -7,9 +7,9 @@

All Games

- @@ -92,7 +92,7 @@
- @if(request()->hasAny(['platform', 'genre', 'year', 'rating_range'])) + @if(request()->hasAny(['platform', 'genre', 'year ', 'rating_range']))
@if(request('platform')) @@ -123,35 +123,48 @@
@endif -
+
@foreach($games as $game) -
-
- {{ $game->name }} -
-
{{ $game->name }}
-

- {{ Str::limit($game->summary, 100) }} -

-
- @if($game->rating) - {{ number_format($game->rating, 1) }} - @endif - @if($game->first_release_date) - - {{ \Carbon\Carbon::parse($game->first_release_date)->format('Y') }} - - @endif -
- - View Details + -
+{{--
--}} +{{--
--}} +{{-- {{ $game->name }}--}} +{{--
--}} +{{--
{{ $game->name }}
--}} +{{--

--}} +{{-- {{ Str::limit($game->summary, 100) }}--}} +{{--

--}} +{{--
--}} +{{-- @if($game->rating)--}} +{{-- {{ number_format($game->rating, 1) }}--}} +{{-- @endif--}} +{{-- @if($game->first_release_date)--}} +{{-- --}} +{{-- {{ \Carbon\Carbon::parse($game->first_release_date)->format('Y') }}--}} +{{-- --}} +{{-- @endif--}} +{{--
--}} +{{-- --}} +{{-- View Details--}} +{{-- --}} +{{--
--}} +{{--
--}} +{{--
--}} @endforeach
diff --git a/resources/views/games/show.blade.php b/resources/views/games/show.blade.php index 058a600..e3a89ff 100644 --- a/resources/views/games/show.blade.php +++ b/resources/views/games/show.blade.php @@ -47,28 +47,40 @@
-
Details
+
Released on
-
Platforms
@foreach($game->platforms()->get() as $platform) {{ $platform->name }} @endforeach
+
+
+
+
+
Genres
+
+
-
Genres
@foreach($game->genres()->get() as $genre) {{ $genre->name }} @endforeach
+
+
- @if($game->rating) +
+
+
Details
+
+
+ @if($game->rating)
Rating
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php new file mode 100644 index 0000000..91dbbed --- /dev/null +++ b/resources/views/index.blade.php @@ -0,0 +1,51 @@ +@extends('layouts.app') + +@section('title', 'ClearGame - Track Your Games. Level Up Your Backlog.') + +@section('content') +
+

+ Track Your Games.
+ Level Up Your Backlog. +

+

+ Organize your gaming journey, discover new titles, and connect with fellow gamers. + Your ultimate companion for managing and completing your game collection. +

+ +
+ +
+
+
+
+
🎮
+

Track Your Progress

+

Keep tabs on your gaming journey and celebrate your achievements.

+
+
+
+
+
📊
+

Discover New Games

+

Find your next favorite game with personalized recommendations.

+
+
+
+
+
👥
+

Connect with Gamers

+

Share your experiences and connect with like-minded gamers.

+
+
+
+
+ +
+

Ready to Level Up Your Gaming Experience?

+ Join ClearGame Today +
+@endsection diff --git a/resources/views/landing.blade.php b/resources/views/landing.blade.php index 6729d98..3e29464 100644 --- a/resources/views/landing.blade.php +++ b/resources/views/landing.blade.php @@ -33,15 +33,7 @@ - + @include('layouts.navigation')
@@ -97,4 +89,4 @@
- \ No newline at end of file + diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 0c39bf9..0cd94c5 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -19,7 +19,29 @@ - +
@@ -44,6 +66,9 @@ {{ Auth::user()->name }}
- + + +
+ @csrf + + + {{ __('Log Out') }} + +
+ + +
+ @endauth + @guest +
+ Login + Sign Up +
+ @endguest
diff --git a/resources/views/lists/index.blade.php b/resources/views/lists/index.blade.php index 895a8e4..5090045 100644 --- a/resources/views/lists/index.blade.php +++ b/resources/views/lists/index.blade.php @@ -4,51 +4,65 @@ @section('content')
-
-

My Lists

- - Create New List - -
+
- @foreach($lists as $list) -
-
-
-
-
{{ $list->name }}
- {{ $list->games_count }} games -
- @if($list->description) -

{{ $list->description }}

- @endif -
-