/** * Creating a flight from user input. * Create a new booking and push $customer->id * and flight->id in. * * @param $request [request user input] * @param $id [getting customer id] */ public function addBookingDetail($request, $id) { $givenInput = $request->all(); $data = $this->model->create($givenInput); $customer = $this->customer->getById($id); return Booking::create(['customer_id' => $customer->id, 'flight_id' => $data->id]); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('flights')->delete(); $cities = Config::get('cities'); $cities2 = Config::get('cities'); //$cities = json_decode($citiesData, true); //$cities2 = json_decode($citiesData2, true); shuffle($cities2); $i = 0; foreach ($cities as $city) { $date = Carbon::create(2016, 1, 1, 0, 0, 0); Flight::create(array('departure' => $city['name'], 'destination' => $cities2[$i]['name'], 'departure_date' => $date->addWeeks(rand(1, 52))->format('Y-m-d'), 'first_class' => $this->random(200.0, 500.0), 'second_class' => $this->random(50.0, 200.0))); if (++$i > 500) { break; } } }