diff --git a/app/Http/Controllers/RentController.php b/app/Http/Controllers/RentController.php index 97b2525..b02b55d 100644 --- a/app/Http/Controllers/RentController.php +++ b/app/Http/Controllers/RentController.php @@ -4,16 +4,37 @@ use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; + +use App\Models\Vehicle; + +use App\Models\Order; + class RentController extends Controller { public function getFindCar() { - return view('find-vehicles'); + return view('find-vehicles', ['type' => 'Car']); + } + + public function findVehicles() { + $request = request()->input(); + $type = $request['type']; + + $vehicles = Vehicle::join('orders', 'vehicles.id', '=', 'orders.vehicle_id') + ->select("vehicles.id", "vehicles.name", "vehicles.brand_id", "vehicles.transmission", "vehicles.cc", "vehicles.price", "vehicles.type", "vehicles.photo", "vehicles.year") + ->where("orders.dropoff_date", "<", $request['pickup_date']) + ->orWhere("orders.pickup_date", ">", $request['dropoff_date']) + ->groupBy("vehicles.id") + ->having('vehicles.available_unit', '>', DB::raw('count(orders.id)')) + ->get(); + + return redirect()->route('rent-'. strtolower($type). 's', ['vehicles' => $vehicles]); } public function getFindMotor() { - return view('find-vehicles'); + return view('find-vehicles', ['type' => 'Motor']); } public function getRentCarForm() @@ -28,11 +49,11 @@ public function getRentMotorForm() public function getRentCars() { - return view('vehicles-list'); + return view('vehicles-list', ['vehicles' => session('vehicles'), 'type' => 'car']); } public function getRentMotors() { - return view('vehicles-list'); + return view('vehicles-list', ['vehicles' => session('vehicles'), 'type' => 'motor']); } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 43957ae..b38e726 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -15,4 +15,19 @@ public function getUserOrders() { return view('order-history'); } + + public function updateProfile() + { + $request = request()->input(); + + $user = auth()->user(); + + $user->phone_1 = $request['phone_1']; + $user->phone_2 = $request['phone_2']; + $user->address_id = $request['address_id']; + $user->address_mlg = $request['address_mlg']; + $user->save(); + + return redirect()->route('index'); + } } diff --git a/database/migrations/2022_05_13_062551_update_users_table.php b/database/migrations/2022_05_13_062551_update_users_table.php index 2b832a9..406ed16 100644 --- a/database/migrations/2022_05_13_062551_update_users_table.php +++ b/database/migrations/2022_05_13_062551_update_users_table.php @@ -14,10 +14,10 @@ public function up() { Schema::table('users', function (Blueprint $table) { - $table->string('phone_1'); - $table->string('phone_2'); - $table->string('address_id'); - $table->string('address_mlg'); + $table->string('phone_1')->nullable(); + $table->string('phone_2')->nullable(); + $table->string('address_id')->nullable(); + $table->string('address_mlg')->nullable(); }); } diff --git a/database/migrations/2022_05_13_083354_add_available_unit_to_vehicles_table.php b/database/migrations/2022_05_13_083354_add_available_unit_to_vehicles_table.php new file mode 100644 index 0000000..9f72ee4 --- /dev/null +++ b/database/migrations/2022_05_13_083354_add_available_unit_to_vehicles_table.php @@ -0,0 +1,32 @@ +integer('available_unit')->nullable()->unsigned(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('vehicles', function (Blueprint $table) { + $table->dropColumn('available_unit'); + }); + } +}; diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.php new file mode 100644 index 0000000..3bdb696 --- /dev/null +++ b/database/seeders/UserSeeder.php @@ -0,0 +1,44 @@ + 'John Doe' , + 'email' => 'johndoe@mail.com', + 'password' => Hash::make('password'), + 'role' => 'admin', + 'email_verified_at' => now() + ], + [ + 'name' => 'Jane Doe' , + 'email' => 'janedoe@mail.com', + 'password' => Hash::make('password'), + 'role' => 'admin', + 'email_verified_at' => now() + ], + [ + 'name' => 'John Smith' , + 'email' => 'johnsmith@mail.com', + 'password' => Hash::make('password'), + 'role' => 'admin', + 'email_verified_at' => now() + ] + ]; + + \DB::table('users')->insert($data); + } +} diff --git a/public/css/app.css b/public/css/app.css index 0e288a9..dd84834 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -688,6 +688,10 @@ select { margin-top: 2rem; margin-bottom: 2rem; } +.my-1 { + margin-top: 0.25rem; + margin-bottom: 0.25rem; +} .ml-3 { margin-left: 0.75rem; } @@ -871,6 +875,9 @@ select { .h-40 { height: 10rem; } +.h-11 { + height: 2.75rem; +} .min-h-screen { min-height: 100vh; } @@ -955,6 +962,9 @@ select { .w-2 { width: 0.5rem; } +.w-11\/12 { + width: 91.666667%; +} .max-w-xl { max-width: 36rem; } @@ -1096,6 +1106,10 @@ select { .gap-2\.5 { gap: 0.625rem; } +.gap-x-5 { + -moz-column-gap: 1.25rem; + column-gap: 1.25rem; +} .space-x-8 > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(2rem * var(--tw-space-x-reverse)); @@ -1109,6 +1123,9 @@ select { .overflow-hidden { overflow: hidden; } +.text-ellipsis { + text-overflow: ellipsis; +} .whitespace-nowrap { white-space: nowrap; } @@ -1189,6 +1206,10 @@ select { --tw-border-opacity: 1; border-color: rgb(226 226 226 / var(--tw-border-opacity)); } +.border-black { + --tw-border-opacity: 1; + border-color: rgb(0 0 0 / var(--tw-border-opacity)); +} .bg-white { --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); @@ -1313,6 +1334,10 @@ select { padding-top: 1.5rem; padding-bottom: 1.5rem; } +.px-0 { + padding-left: 0px; + padding-right: 0px; +} .pt-52 { padding-top: 13rem; } @@ -1806,6 +1831,14 @@ select { grid-template-columns: repeat(4, minmax(0, 1fr)); } + .lg\:grid-cols-2 { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + + .lg\:grid-rows-4 { + grid-template-rows: repeat(4, minmax(0, 1fr)); + } + .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; diff --git a/public/js/navbar_script.js b/public/js/navbar_script.js index ca8ff16..19925a7 100644 --- a/public/js/navbar_script.js +++ b/public/js/navbar_script.js @@ -9,24 +9,24 @@ var toggleMenu = document.getElementById('menu-toggle'); var menuList = document.getElementById('menu-list'); var menuOption = document.getElementsByClassName('rent-menu-option'); +toggleMenu.onclick = function (event) { + event.preventDefault(); + menuList.style.maxHeight = menuList.style.maxHeight == '0px' ? '1000px' : '0px'; +}; + menuOption[0].onclick = function (event) { event.preventDefault(); - window.location.href = window.location.origin + '/rent/cars'; + window.location.href = window.location.origin + '/find/car'; }; menuOption[1].onclick = function (event) { event.preventDefault(); - window.location.href = window.location.origin + '/rent/motors'; + window.location.href = window.location.origin + '/find/motor'; }; showButton.onclick = function (event) { event.preventDefault(); showMenu.style.display = showMenu.style.display == 'none' ? 'block' : 'none'; }; - -toggleMenu.onclick = function (event) { - event.preventDefault(); - menuList.style.maxHeight = menuList.style.maxHeight == '0px' ? '1000px' : '0px'; -}; /******/ })() ; \ No newline at end of file diff --git a/resources/js/navbar_script.js b/resources/js/navbar_script.js index 55f7742..f81b6be 100644 --- a/resources/js/navbar_script.js +++ b/resources/js/navbar_script.js @@ -4,22 +4,22 @@ const toggleMenu = document.getElementById('menu-toggle'); const menuList = document.getElementById('menu-list'); const menuOption = document.getElementsByClassName('rent-menu-option'); +toggleMenu.onclick = (event) => { + event.preventDefault(); + menuList.style.maxHeight = menuList.style.maxHeight == '0px' ? '1000px': '0px'; +} + menuOption[0].onclick = (event) => { event.preventDefault(); - window.location.href = window.location.origin + '/rent/cars'; + window.location.href = window.location.origin + '/find/car'; } menuOption[1].onclick = (event) => { event.preventDefault(); - window.location.href = window.location.origin + '/rent/motors'; + window.location.href = window.location.origin + '/find/motor'; } showButton.onclick = (event) => { event.preventDefault(); showMenu.style.display = showMenu.style.display == 'none' ? 'block': 'none'; -} - -toggleMenu.onclick = (event) => { - event.preventDefault(); - menuList.style.maxHeight = menuList.style.maxHeight == '0px' ? '1000px': '0px'; } \ No newline at end of file diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index c6dbe30..4e7116f 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -2,26 +2,30 @@