Files

83 lines
2.8 KiB
PHP
Raw Permalink Normal View History

2026-03-15 17:08:23 +07:00
<?php
namespace Modules\Booking\Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class RoomTableSeeder extends Seeder
{
public function run(): void
{
$roomTypes = [
['id' => 1, 'name' => 'Deluxe Room', 'price_min' => 150, 'price_max' => 220],
['id' => 2, 'name' => 'Superior Room', 'price_min' => 130, 'price_max' => 190],
['id' => 3, 'name' => 'Premier Room', 'price_min' => 200, 'price_max' => 260],
['id' => 4, 'name' => 'Executive Room', 'price_min' => 250, 'price_max' => 320],
['id' => 5, 'name' => 'Family Room', 'price_min' => 180, 'price_max' => 240],
['id' => 6, 'name' => 'Suite', 'price_min' => 350, 'price_max' => 500],
];
$views = ['City View', 'Garden View', 'Pool View', 'Marina View', 'Skyline View'];
$rooms = [];
$imagePool = range(1, 46); // images 146
for ($i = 1; $i <= 20; $i++) {
$type = $roomTypes[array_rand($roomTypes)];
$image = $imagePool[array_rand($imagePool)].'.jpg';
$banner = $imagePool[array_rand($imagePool)].'.jpg';
// Random gallery 68 images
shuffle($imagePool);
$galleryImages = array_slice($imagePool, 0, rand(6, 8));
$galleryImages = array_map(fn ($img) => $img.'.jpg', $galleryImages);
$roomNumber = 100 + $i;
$typeSlug = strtolower(str_replace(' ', '-', $type['name']));
$regular = rand($type['price_min'], $type['price_max']);
$offer = $regular - rand(10, 30);
$rooms[] = [
'restaurant_id' => 1,
'hotel_id' => 1,
'floor_id' => rand(1, 6),
'room_type_id' => $type['id'],
'room_number' => $roomNumber,
'room_code' => strtoupper(substr($typeSlug, 0, 3)).$roomNumber,
'max_adults' => rand(2, 4),
'max_children' => rand(0, 2),
'has_balcony' => rand(0, 1),
'has_bathtub' => rand(0, 1),
'view_type' => $views[array_rand($views)],
'slug' => $roomNumber.'-'.$typeSlug,
'image' => $image,
'banner_image' => $banner,
'gallery_images' => json_encode($galleryImages),
'description' => $type['name'].' with modern amenities, designed for comfort and a premium Singapore hotel experience.',
'regular_price' => $regular,
'offer_price' => $offer,
'is_clean' => true,
'is_available' => true,
'status' => 1,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
DB::table('rooms')->insert($rooms);
}
}