<?php

use Illuminate\Database\Seeder;

class UmrahTripReservationSeeder extends Seeder
{
    protected $faker;
    public function __construct()
    {
        $this->faker = \Faker\Factory::create();
    }

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        foreach (\App\UmrahTrip::cursor() as $umrahTrip) {
            foreach (\App\User::where('role', 'user')->cursor() as $user) {
                $personCount = $this->faker->randomNumber(1);
                $total = $personCount*$umrahTrip->price_per_person;
                factory(\App\UmrahTripReservation::class, 5)->create(
                    [
                        'name' => $user->name,
                        'email' => $user->email,
                        'phone' => $user->phone,
                        'user_id' => $user->id,
//                        'umrah_trip_type' => $umrahTrip->umrah_trip_type,
                        'umrah_trip_date' => $umrahTrip->umrah_trip_date[0],
                        'departure_city' => $umrahTrip->departure_city,
                        'arrival_city' => $umrahTrip->arrival_city,
                        'rally_point_info' => $umrahTrip->rally_point_info,
                        'person_count' => $personCount,
                        'price_per_person' => $umrahTrip->price_per_person,
                        'total' => $total,
                        'house_type' => $umrahTrip->house_type,
                        'umrah_trip_id' => $umrahTrip->id,
                    ]
                );
            }

        }
    }
}
