Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
add vehicle-list
Browse files Browse the repository at this point in the history
  • Loading branch information
alyafitrin committed May 14, 2022
2 parents bc96305 + 53a536a commit 5175f3e
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 41 deletions.
29 changes: 25 additions & 4 deletions app/Http/Controllers/RentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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']);
}
}
15 changes: 15 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
8 changes: 4 additions & 4 deletions database/migrations/2022_05_13_062551_update_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('vehicles', function (Blueprint $table) {
$table->integer('available_unit')->nullable()->unsigned();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('vehicles', function (Blueprint $table) {
$table->dropColumn('available_unit');
});
}
};
44 changes: 44 additions & 0 deletions database/seeders/UserSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$data = [
[
'name' => 'John Doe' ,
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'admin',
'email_verified_at' => now()
],
[
'name' => 'Jane Doe' ,
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'admin',
'email_verified_at' => now()
],
[
'name' => 'John Smith' ,
'email' => '[email protected]',
'password' => Hash::make('password'),
'role' => 'admin',
'email_verified_at' => now()
]
];

\DB::table('users')->insert($data);
}
}
33 changes: 33 additions & 0 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -871,6 +875,9 @@ select {
.h-40 {
height: 10rem;
}
.h-11 {
height: 2.75rem;
}
.min-h-screen {
min-height: 100vh;
}
Expand Down Expand Up @@ -955,6 +962,9 @@ select {
.w-2 {
width: 0.5rem;
}
.w-11\/12 {
width: 91.666667%;
}
.max-w-xl {
max-width: 36rem;
}
Expand Down Expand Up @@ -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));
Expand All @@ -1109,6 +1123,9 @@ select {
.overflow-hidden {
overflow: hidden;
}
.text-ellipsis {
text-overflow: ellipsis;
}
.whitespace-nowrap {
white-space: nowrap;
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions public/js/navbar_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
/******/ })()
;
14 changes: 7 additions & 7 deletions resources/js/navbar_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
32 changes: 22 additions & 10 deletions resources/views/components/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@
<div class="w-screen h-1 bg-lilac-100"></div>
<div class="navbar flex justify-between">
<a href="{{ url('/') }}"><div class="navbar-logo basis-1/4 text-lilac-100">Rent.ly</div></a>
<div class="basis-3/4 flex justify-between sm:max-h-0 md:max-h-0" id="menu-list">
<div class="basis-3/4 flex justify-between sm:max-h-0 md:max-h-0 bg-white" id="menu-list">
<div class="navbar-links flex p-3 m-3">
@guest
<?php $values = array('Rent', 'Guide', 'Help', 'About'); ?>
<?php $values = array('Rent' => 'rent', 'Guide' => 'guide', 'Help' => 'help', 'About' => 'about'); ?>
@endguest
@auth
<?php $values = array('Rent', 'My order', 'Guide', 'Help', 'About'); ?>
@if(auth()->user()->hasRole('user'))
<?php $values = array('Rent' => 'rent', 'My order' => 'me/order', 'Guide' => 'guide', 'Help' => 'help', 'About' => 'about'); ?>
@else
<?php $values = array('Order' => 'dashboard/orders', 'Product' => 'dashboard/vehicles', 'Customer' => 'dashboard/customers') ?>
@endif
@endauth
@foreach($values as $value)
<a href="{{ $isRent($value) ? '' : url(strtolower($value)) }}">
<div id="{{ $isRent($value) ? 'rent-button' : '' }}" class="relative navbar-option mx-6 whitespace-nowrap {{ Auth::check() ? 'w-24' : 'w-20' }}">
<p class="inline-block w-8 px-2 text-center {{ $isSelected($value) ? 'font-bold' : '' }}"> {{ $value }} </p>
@if($isRent($value))
@foreach($values as $key => $value)
<a href="{{ $isRent($key) ? '' : url($value) }}">
<div id="{{ $isRent($key) ? 'rent-button' : '' }}" class="relative navbar-option mx-6 whitespace-nowrap {{ Auth::check() ? 'w-24' : 'w-20' }}">
<p class="inline-block w-8 px-2 text-center {{ $isSelected($key) ? 'font-bold' : '' }}"> {{ $key }} </p>
@if($isRent($key))
<img src="{{ asset('images/down-arrow.svg') }}" class="inline-block w-5 ml-3 pl-1">
<div id="rent-menu" class="rent-menu z-10 hidden absolute w-40 font-normal">
<div id="rent-menu" class="rent-menu z-10 hidden absolute w-40 font-normal bg-white">
<div class="rent-menu-option px-2 py-1 bg-gray hover:bg-lilac-100 hover:text-white">
Rent Car
</div>
<div class="rent-menu-option px-2 py-1 bg-gray hover:bg-lilac-100 hover:text-white">
Rent Motorcycle </a>
Rent Motorcycle
</div>
</div>
@endif
Expand All @@ -39,6 +43,14 @@
</a>
@endguest
@auth
<a href="{{ '/me/profile' }}"><div class="mx-2 my-1 border border-black px-2 py-1 rounded-lg w-20 h-11 text-ellipsis overflow-hidden">
@if(auth()->user()->hasRole('admin'))
<p class="text-xs">Admin</p>
@else
<p class="text-xs">Customer</p>
@endif
<p class="text-sm font-bold text-lilac-100">{{ auth()->user()->name }}</p>
</div></a>
<form action="{{ url('/logout') }}" method="post">
@csrf
<x-button filled=true> {{ __('Logout') }}</x-button>
Expand Down
Loading

0 comments on commit 5175f3e

Please sign in to comment.