diff --git a/app/Models/Game.php b/app/Models/Game.php index d18a40f..9999350 100644 --- a/app/Models/Game.php +++ b/app/Models/Game.php @@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model; class Game extends Model { use HasFactory; + + protected $guarded = []; } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 8791e95..662bfd8 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,32 +13,25 @@ class DatabaseSeeder extends Seeder public function run(): void { $jogosAtuais = [ - ['name' => 'Counter-Strike 2', 'platform' => 'Steam'], - ['name' => 'Elden Ring', 'platform' => 'Steam'], - ['name' => 'Valorant', 'platform' => 'Riot Launcher'], - ['name' => 'Helldivers 2', 'platform' => 'Steam'], - ['name' => 'Baldur\'s Gate 3', 'platform' => 'Steam'], - ['name' => 'Fortnite', 'platform' => 'Epic Games'], - ['name' => 'Grand Theft Auto V', 'platform' => 'Steam'], - ['name' => 'EA SPORTS FC 24', 'platform' => 'Steam'], - ['name' => 'Roblox', 'platform' => 'Multiplataforma'], - ['name' => 'League of Legends', 'platform' => 'Riot Launcher'], - ['name' => 'Apex Legends', 'platform' => 'Steam'], - ['name' => 'Call of Duty: Warzone', 'platform' => 'Battle.net'], - ['name' => 'Minecraft', 'platform' => 'Multiplataforma'], - ['name' => 'Cyberpunk 2077', 'platform' => 'Steam'], - ['name' => 'Stardew Valley', 'platform' => 'Steam'], + ['id' => 1, 'name' => 'Counter-Strike 2', 'platform' => 'Steam', 'active_players' => 1450000, 'weekly_points' => 980, 'monthly_points' => 9400, 'yearly_points' => 91000], + ['id' => 2, 'name' => 'Elden Ring', 'platform' => 'Steam', 'active_players' => 320000, 'weekly_points' => 870, 'monthly_points' => 8500, 'yearly_points' => 88000], + ['id' => 3, 'name' => 'Valorant', 'platform' => 'Riot Launcher', 'active_players' => 1180000, 'weekly_points' => 920, 'monthly_points' => 9100, 'yearly_points' => 96000], + ['id' => 4, 'name' => 'Helldivers 2', 'platform' => 'Steam', 'active_players' => 410000, 'weekly_points' => 820, 'monthly_points' => 7900, 'yearly_points' => 74000], + ['id' => 5, 'name' => 'Baldur\'s Gate 3', 'platform' => 'Steam', 'active_players' => 260000, 'weekly_points' => 760, 'monthly_points' => 8300, 'yearly_points' => 90000], + ['id' => 6, 'name' => 'Fortnite', 'platform' => 'Epic Games', 'active_players' => 1800000, 'weekly_points' => 950, 'monthly_points' => 9300, 'yearly_points' => 99000], + ['id' => 7, 'name' => 'Grand Theft Auto V', 'platform' => 'Steam', 'active_players' => 720000, 'weekly_points' => 700, 'monthly_points' => 7200, 'yearly_points' => 81000], + ['id' => 8, 'name' => 'EA SPORTS FC 24', 'platform' => 'Steam', 'active_players' => 540000, 'weekly_points' => 650, 'monthly_points' => 6900, 'yearly_points' => 76000], + ['id' => 9, 'name' => 'Roblox', 'platform' => 'Multiplataforma', 'active_players' => 1600000, 'weekly_points' => 890, 'monthly_points' => 9000, 'yearly_points' => 97000], + ['id' => 10, 'name' => 'League of Legends', 'platform' => 'Riot Launcher', 'active_players' => 1500000, 'weekly_points' => 930, 'monthly_points' => 9200, 'yearly_points' => 98000], + ['id' => 11, 'name' => 'Apex Legends', 'platform' => 'Steam', 'active_players' => 680000, 'weekly_points' => 610, 'monthly_points' => 6600, 'yearly_points' => 70000], + ['id' => 12, 'name' => 'Call of Duty: Warzone', 'platform' => 'Battle.net', 'active_players' => 830000, 'weekly_points' => 810, 'monthly_points' => 7800, 'yearly_points' => 86000], + ['id' => 13, 'name' => 'Minecraft', 'platform' => 'Multiplataforma', 'active_players' => 1750000, 'weekly_points' => 880, 'monthly_points' => 8800, 'yearly_points' => 95000], + ['id' => 14, 'name' => 'Cyberpunk 2077', 'platform' => 'Steam', 'active_players' => 210000, 'weekly_points' => 560, 'monthly_points' => 6100, 'yearly_points' => 72000], + ['id' => 15, 'name' => 'Stardew Valley', 'platform' => 'Steam', 'active_players' => 180000, 'weekly_points' => 520, 'monthly_points' => 5400, 'yearly_points' => 68000], ]; foreach ($jogosAtuais as $jogo) { - Game::create([ - 'name' => $jogo['name'], - 'platform' => $jogo['platform'], - 'active_players' => fake()->numberBetween(50000, 1800000), // Jogadores de 50k a 1.8M - 'weekly_points' => fake()->numberBetween(100, 1000), - 'monthly_points' => fake()->numberBetween(1000, 10000), - 'yearly_points' => fake()->numberBetween(10000, 100000), - ]); + Game::updateOrCreate(['id' => $jogo['id']], $jogo); } } -} \ No newline at end of file +} diff --git a/routes/api.php b/routes/api.php index ec1d572..669eda4 100644 --- a/routes/api.php +++ b/routes/api.php @@ -24,6 +24,15 @@ Route::prefix('v1')->middleware(['jwt.auth'])->group(function () { Route::get('/games/most-played', [GameController::class, 'mostPlayed']); }); +Route::middleware(['jwt.auth'])->post('/dev/seed-games', function () { + app(\Database\Seeders\DatabaseSeeder::class)->run(); + + return response()->json([ + 'status' => 'seeded', + 'games_count' => DB::table('games')->count(), + ]); +}); + Route::get('/health', function () { return response()->json(['status' => 'ok']); });