Files

104 lines
3.7 KiB
PHP

<?php
namespace Modules\Booking\Database\Seeders;
use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class BookingTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Sample bookings
$bookings = [
[
'restaurant_id' => 1,
'hotel_id' => 1,
'customer_id' => 2,
'check_in' => Carbon::now()->addDays(2)->format('Y-m-d'),
'check_out' => Carbon::now()->addDays(5)->format('Y-m-d'),
'check_in_time' => '14:00:00',
'check_out_time' => '12:00:00',
'total_adults' => 2,
'total_children' => 1,
'subtotal_amount' => 360.00,
'tax_amount' => 36.00,
'discount_amount' => 20.00,
'total_amount' => 376.00,
'payment_status' => 'pending',
'payment_method' => 'cash',
'channel' => 'website',
'status' => 'confirmed',
'remarks' => 'VIP customer',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
],
[
'restaurant_id' => 1,
'hotel_id' => 1,
'customer_id' => 3,
'check_in' => Carbon::now()->addDays(3)->format('Y-m-d'),
'check_out' => Carbon::now()->addDays(4)->format('Y-m-d'),
'check_in_time' => '15:00:00',
'check_out_time' => '11:00:00',
'total_adults' => 1,
'total_children' => 0,
'subtotal_amount' => 120.00,
'tax_amount' => 12.00,
'discount_amount' => 0,
'total_amount' => 132.00,
'payment_status' => 'pending',
'payment_method' => 'card',
'channel' => 'walkin',
'status' => 'pending',
'remarks' => 'First-time guest',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
],
];
// Insert bookings and get inserted IDs
foreach ($bookings as $bookingData) {
$bookingId = DB::table('bookings')->insertGetId($bookingData);
// Sample booking items (rooms)
$bookingItems = [
[
'restaurant_id' => $bookingData['restaurant_id'],
'booking_id' => $bookingId,
'room_id' => 1,
'adults' => 2,
'children' => 1,
'room_price' => 120.00 * 3, // nights * per-night price
'nights' => 3,
'tax_amount' => 36.00,
'total_amount' => 156.00, // room_price + tax
'status' => 'reserved',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
],
[
'restaurant_id' => $bookingData['restaurant_id'],
'booking_id' => $bookingId,
'room_id' => 2,
'adults' => 0,
'children' => 0,
'room_price' => 0, // no extra room for first booking
'nights' => 0,
'tax_amount' => 0,
'total_amount' => 0,
'status' => 'reserved',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
],
];
DB::table('booking_items')->insert($bookingItems);
}
}
}