/** * create rental * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function create(Request $request) { //validation $this->customValidation(); $this->validation($request); //insert rental $rental = Rental::create(['car-id' => $request->get('car-id'), 'client-id' => $request->get('client-id'), 'date-from' => $request->get('date-from'), 'date-to' => $request->get('date-to')]); return response()->json(['id' => $rental->id]); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::create(); # Kosongin isi tabel DB::table('anggota')->delete(); DB::table('detailanggota')->delete(); DB::table('rental')->delete(); $rental = Rental::create(array('nama' => 'Hanzo', 'alamat' => 'Jalan Buah Batu')); $this->command->info('Data rental telah diisi!'); #Faker testing $anggota1 = Anggota::create(array('nama' => $faker->name, 'id_rental' => $rental->id)); $anggota2 = Anggota::create(array('nama' => $faker->name, 'id_rental' => $rental->id)); $anggota3 = Anggota::create(array('nama' => $faker->name, 'id_rental' => $rental->id)); # Buat anggota $arvin = Anggota::create(array('nama' => 'Arvin Chendriyana Supriyadi', 'id_rental' => $rental->id)); $aulia = Anggota::create(array('nama' => 'Aulia Marchita Ramadhani', 'id_rental' => $rental->id)); $elmo = Anggota::create(array('nama' => 'Elmo Aryaputra', 'id_rental' => $rental->id)); # Informasi ketika anggota telah diisi. $this->command->info('Anggota telah diisi!'); # Buat Detail Anggota DetailAnggota::create(array('jenisKelamin' => 'Laki-laki', 'alamat' => 'Jalan Sidomukti No. 78', 'telp' => '08112282323', 'id_anggota' => $arvin->id)); DetailAnggota::create(array('jenisKelamin' => 'Perempuan', 'alamat' => 'Tangerang', 'telp' => '081310713931', 'id_anggota' => $aulia->id)); DetailAnggota::create(array('jenisKelamin' => 'Laki-laki', 'alamat' => 'Jalan Cigadung', 'telp' => '082117713169', 'id_anggota' => $elmo->id)); # Informasi ketika detail telah diisi. $this->command->info('Detail anggota telah diisi!'); #Seeder Game DB::table('game')->delete(); DB::table('anggota_game')->delete(); $fallout_4 = Game::create(array('judul' => 'Fallout 4', 'genre' => 'RPG', 'developer' => 'Bethesda')); $witcher_3 = Game::create(array('judul' => 'The Witcher 3: Wild Hunt', 'genre' => 'RPG', 'developer' => 'CD Projekt RED')); $kh_3 = Game::create(array('judul' => 'Kingdom Hearts 3', 'genre' => 'RPG', 'developer' => 'Square Enix')); $arvin->game()->attach($fallout_4->id); $arvin->game()->attach($witcher_3->id); $arvin->game()->attach($kh_3->id); $aulia->game()->attach($kh_3->id); $aulia->game()->attach($fallout_4->id); $elmo->game()->attach($witcher_3->id); # Tampilkan bila berhasil diisi $this->command->info('Anggota beserta game telah diisi!'); }
/** * @param RentalRequest $request * @return $this|\Illuminate\Http\RedirectResponse */ public function create(RentalRequest $request) { $departing_date = Carbon::parse($request->departing_date); if ($request->trip_type == "round_trip") { $destination_date = Carbon::parse($request->returning_date); if ($departing_date->gte($destination_date) || $departing_date->lte(Carbon::today())) { return redirect()->back()->withErrors('Invalid Date range Input')->withInput(); } $input = $request->except(['departing_date', 'destination_date']); $input = array_add($input, 'departing_date', $departing_date); $input = array_add($input, 'destination_date', $destination_date); } elseif ($request->trip_type == "one_way") { if ($departing_date->lte(Carbon::today())) { return redirect()->back()->withErrors('Invalid Date Input')->withInput(); } $input = $request->except(['departing_date', 'destination_date']); $input = array_add($input, 'departing_date', $departing_date); } $rental_request = Rental::create($input); session()->put('request', $rental_request); //Event firing //listen to this event in order to send sms and email return redirect()->route('rental_feedback'); }
public function process($type, $id) { // create our rental data $rental = array('user_id' => Auth::user()->id, 'car_id' => (int) $id, 'numDays' => (int) Input::get('numDays'), 'initMileage' => Input::get('initMileage'), 'firstPayment' => Input::get('firstPayment'), 'state' => 0); $rental = Rental::create($rental); //create rental $car = Car::find($id); //get car return Redirect::to('/rent/' . $car->type . '/' . $car->id . '/confirm'); //redirect to confirmation page }