You've already forked Atomcms-edit
80 lines
2.5 KiB
PHP
Executable File
80 lines
2.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Miscellaneous\WebsiteSetting;
|
|
use App\Models\RadioListenerPoint;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class RadioTestSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Ensure radio settings exist
|
|
WebsiteSetting::updateOrCreate(
|
|
['key' => 'radio_enabled'],
|
|
['value' => '1', 'comment' => 'Enable radio system'],
|
|
);
|
|
|
|
WebsiteSetting::updateOrCreate(
|
|
['key' => 'points_enabled'],
|
|
['value' => '1', 'comment' => 'Enable points system'],
|
|
);
|
|
|
|
WebsiteSetting::updateOrCreate(
|
|
['key' => 'points_per_minute'],
|
|
['value' => '2', 'comment' => 'Points awarded per minute of listening'],
|
|
);
|
|
|
|
WebsiteSetting::updateOrCreate(
|
|
['key' => 'max_points_per_day'],
|
|
['value' => '100', 'comment' => 'Maximum points per day per user'],
|
|
);
|
|
|
|
WebsiteSetting::updateOrCreate(
|
|
['key' => 'radio_shouts_enabled'],
|
|
['value' => '1', 'comment' => 'Enable shouts system'],
|
|
);
|
|
|
|
// Create test users with points
|
|
$testUsers = [
|
|
['username' => 'TopListener', 'points' => 1500],
|
|
['username' => 'MusicFan', 'points' => 1200],
|
|
['username' => 'RadioExpert', 'points' => 800],
|
|
['username' => 'StreamLover', 'points' => 600],
|
|
['username' => 'CasualListener', 'points' => 300],
|
|
];
|
|
|
|
foreach ($testUsers as $userData) {
|
|
$user = User::firstOrCreate(
|
|
['username' => $userData['username']],
|
|
[
|
|
'mail' => strtolower($userData['username']) . '@test.com',
|
|
'password' => Hash::make('password123'),
|
|
'radio_points' => $userData['points'],
|
|
'account_created' => now(),
|
|
'ip_register' => '127.0.0.1',
|
|
'ip_current' => '127.0.0.1',
|
|
],
|
|
);
|
|
|
|
// Create some point history
|
|
for ($i = 0; $i < 5; $i++) {
|
|
RadioListenerPoint::create([
|
|
'user_id' => $user->id,
|
|
'points' => rand(5, 50),
|
|
'reason' => 'Luisteren',
|
|
'earned_at' => now()->subDays(rand(1, 30))->subHours(rand(1, 23)),
|
|
]);
|
|
}
|
|
}
|
|
|
|
$this->command->info('Radio test data seeded successfully!');
|
|
}
|
|
}
|