67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use App\Models\Admin;
|
|
use App\Models\Hotel;
|
|
use App\Models\RoomType;
|
|
use App\Models\RoomAvailability;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Создать админа
|
|
$admin = Admin::firstOrCreate([
|
|
'email' => 'admin@hotels.ru',
|
|
], [
|
|
'name' => 'Admin User',
|
|
'password' => Hash::make('password'),
|
|
]);
|
|
|
|
// Создать отель
|
|
$hotel = Hotel::create([
|
|
'name' => 'Grand Hotel',
|
|
'address' => '123 Main St',
|
|
]);
|
|
|
|
$roomType1 = RoomType::create([
|
|
'hotel_id' => $hotel->id,
|
|
'name' => 'Двухместный',
|
|
'capacity' => 2,
|
|
'base_price' => 5000,
|
|
]);
|
|
|
|
$roomType2 = RoomType::create([
|
|
'hotel_id' => $hotel->id,
|
|
'name' => 'Люкс',
|
|
'capacity' => 4,
|
|
'base_price' => 10000,
|
|
]);
|
|
|
|
$startDate = now()->startOfDay();
|
|
$endDate = now()->addDays(30)->startOfDay();
|
|
|
|
for ($date = $startDate; $date <= $endDate; $date->modify('+1 day')) {
|
|
RoomAvailability::create([
|
|
'room_type_id' => $roomType1->id,
|
|
'date' => $date->format('Y-m-d'),
|
|
'is_available' => true,
|
|
'price_override' => null,
|
|
]);
|
|
|
|
RoomAvailability::create([
|
|
'room_type_id' => $roomType2->id,
|
|
'date' => $date->format('Y-m-d'),
|
|
'is_available' => true,
|
|
'price_override' => null,
|
|
]);
|
|
}
|
|
}
|
|
} |