<?php

use Illuminate\Database\Seeder;

class HotelReservationSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        foreach (\App\Hotel::cursor() as $hotel) {
            $addedServicePrice = array_random($hotel->added_service_price, 2);
            foreach (\App\User::where('users.role', 'user')->cursor() as $user) {
                factory(\App\HotelReservation::class, 5)->create(
                    [
                        'name' => $user->name,
                        'user_id' => $user->id,
                        'email' => $user->email,
                        'phone' => $user->phone,
                        'hotel_email' => $hotel->email,
                        'hotel_address' => $hotel->address,
                        'hotel_image' => $hotel->images[0],
                        'room_type' => array_random($hotel->room_type),
                        'added_service' => array_random($hotel->added_service, 2),
                        'added_service_price' => array_random($hotel->added_service_price, 2),
                        'total' => array_sum($addedServicePrice),
                        'city_id' => $hotel->city_id,
                        'hotel_id' => $hotel->id,
                    ]);
            }
        }
    }
}
