예제 #1
0
 public function index()
 {
     $totalTrips = Trip::all()->count();
     $totalTravelCompanies = TravelCompany::all()->count();
     $totalUsers = User::all()->count();
     $totalPaidBookings = Booking::where('status', 'paid')->count();
     $totalBus = Rental::all()->count();
     return view('admin.dashboard', ['tT' => $totalTrips, 'tU' => $totalUsers, 'tP' => $totalPaidBookings, 'tC' => $totalTravelCompanies, 'tB' => $totalBus]);
 }
 private function createRentalRecord($invId, $customerId, $kioskId)
 {
     $rental = new Rental();
     $rental->inventory_id = $invId;
     $rental->customer_id = $customerId;
     $rental->rental_kiosk_id = $kioskId;
     $rental->rentalDate = Carbon::now('America/New_York')->toDateTimeString();
     $rental->save();
     return $rental->id;
 }
예제 #3
0
 /**
  * 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!');
 }
예제 #4
0
 public function customValidation()
 {
     //max rent day must be 3 days
     Validator::extend('checkMaxRentDay', function ($attribute, $value, $parameters, $validator) {
         //check if duration is > 3 days
         if (Input::get('date-from') != null && Input::get('date-to') != null) {
             $datefrom = Carbon::createFromFormat('Y-m-d', Input::get('date-from'));
             $dateto = Carbon::createFromFormat('Y-m-d', Input::get('date-to'));
             if ($datefrom->diffInDays($dateto) > 3) {
                 return false;
             }
         }
         return true;
     });
     //validation message replacer
     Validator::replacer('checkMaxRentDay', function ($attribute, $value, $parameters, $validator) {
         return 'Maximal rent day is 3 days';
     });
     //check car is already rented
     Validator::extend('checkRentedCar', function ($attribute, $value, $parameters, $validator) {
         if (Input::get('date-from') != null && Input::get('date-to') != null) {
             $rented = Rental::where('car-id', $value)->where('id', '<>', $parameters[0])->where('date-from', '<=', Input::get('date-to'))->where('date-to', '>=', Input::get('date-from'))->get();
             return $rented->isEmpty();
         }
         return true;
     });
     Validator::replacer('checkRentedCar', function ($attribute, $value, $parameters, $validator) {
         return 'Car still rented';
     });
     //check if client is renting a car in selected date
     Validator::extend('checkClientRent', function ($attribute, $value, $parameters, $validator) {
         if (Input::get('date-from') != null && Input::get('date-to') != null) {
             $clientrent = Rental::where('client-id', $value)->where('id', '<>', $parameters[0])->where('date-from', '<=', Input::get('date-to'))->where('date-to', '>=', Input::get('date-from'))->get();
             return $clientrent->isEmpty();
         }
         return true;
     });
     Validator::replacer('checkClientRent', function ($attribute, $value, $parameters, $validator) {
         return 'Client is still renting a car';
     });
 }
예제 #5
0
 public function receipt($id)
 {
     if (Auth::check()) {
         $rental = Rental::find($id);
         $car = Car::find($rental->car_id);
         return view('history.receipt', compact('rental', 'car'));
     } else {
         return Redirect::to('/');
     }
 }
예제 #6
0
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function delete($id)
 {
     Rental::find($id)->delete();
     return redirect()->route('bus_request');
 }
예제 #7
0
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::get('relasi-1', function () {
    $anggota = Anggota::where('nama', '=', 'Arvin Chendriyana Supriyadi')->first();
    return $anggota->detailanggota->alamat;
});
Route::get('relasi-2', function () {
    $anggota = Anggota::where('nama', '=', 'Arvin Chendriyana Supriyadi')->first();
    return $anggota->rental->nama;
});
Route::get('relasi-3', function () {
    $rental = Rental::where('nama', '=', 'Hanzo')->first();
    foreach ($rental->anggota as $temp) {
        echo '<li> Nama : ' . $temp->nama . '</li>';
    }
});
Route::get('relasi-4', function () {
    $arvin = Anggota::where('nama', '=', 'Arvin Chendriyana Supriyadi')->first();
    foreach ($arvin->game as $temp) {
        echo '<li>' . $temp->judul . '</li>';
    }
});
Route::get('relasi-5', function () {
    $fallout_4 = Game::where('judul', '=', 'Fallout 4')->first();
    foreach ($fallout_4->anggota as $temp) {
        echo '<li> Nama : ' . $temp->nama . '</li>';
    }
예제 #8
0
 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
 }
예제 #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //
     $rental = \App\Rental::find($id);
     if ($rental->delete()) {
         return response()->json(['rentals' => [$rental]], 201);
     } else {
         return response()->json(['success' => false], 401);
     }
 }