Added DatabaseSeeder for roles, users, wallets, games, promos, stats

This commit is contained in:
2025-09-06 11:43:19 +02:00
parent 9a4800f6c2
commit 7e311fbe27
2 changed files with 59 additions and 10 deletions

View File

@@ -2,22 +2,54 @@
namespace Database\Seeders; namespace Database\Seeders;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\Wallet;
use App\Models\Game;
use App\Models\PromoCode;
use Spatie\Permission\Models\Role;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder
{ {
/**
* Seed the application's database.
*/
public function run(): void public function run(): void
{ {
// User::factory(10)->create(); // Roles (Spatie)
Role::create(['name' => 'admin']);
Role::create(['name' => 'player']);
Role::create(['name' => 'vip']);
User::factory()->create([ // Test User (Player)
'name' => 'Test User', $player = User::factory()->create([
'email' => 'test@example.com', 'name' => 'Test Player',
'email' => 'player@example.com',
'password' => bcrypt('password'),
'is_kyc_verified' => true,
'vip_level' => 1,
]); ]);
$player->assignRole('player', 'vip');
// Test Admin
$admin = User::factory()->create([
'name' => 'Test Admin',
'email' => 'admin@example.com',
'password' => bcrypt('password'),
'is_kyc_verified' => true,
'vip_level' => 0,
]);
$admin->assignRole('admin');
// Wallets
Wallet::create(['user_id' => $player->id, 'balance' => 1000.00]);
Wallet::create(['user_id' => $admin->id, 'balance' => 0.00]);
// Games
Game::create(['name' => 'Plinko', 'slug' => 'plinko', 'thumbnail_url' => 'https://placehold.co/300x200', 'category' => 'plinko']);
Game::create(['name' => 'Slots', 'slug' => 'slots', 'thumbnail_url' => 'https://placehold.co/300x200', 'category' => 'slots']);
// Promo Codes
PromoCode::create(['code' => 'WELCOME100', 'value' => 100.00, 'uses_remaining' => -1, 'is_active' => true]);
// Player Stats (initial)
\App\Models\PlayerStats::create(['user_id' => $player->id, 'total_winnings' => 0.00, 'total_bets' => 0.00, 'play_count' => 0]);
} }
} }

View File

@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class PlayerStatsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}