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

Commit

Permalink
modify user order history page
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed May 15, 2022
1 parent dda1784 commit 0ac880c
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function store(LoginRequest $request)
return redirect(route('admin_dashboard'));
}

return back()->withInput();
return redirect()->back()->withInput();
}

/**
Expand Down
57 changes: 57 additions & 0 deletions app/Http/Controllers/RentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

use App\Models\Order;

use DateTime;

class RentController extends Controller
{
public function getFindCar()
Expand Down Expand Up @@ -71,4 +73,59 @@ public function getRentMotors()

return view('vehicles-list', ['vehicles' => session('vehicles'), 'pickup_date' => session('pickup_date'), 'dropoff_date' => session('dropoff_date'), 'type' => 'Motor']);
}

public function rentVehicle($type, $id)
{
$request = request()->input();

$vehicle = Vehicle::find($id);

$id_card_filename = $id . '_'.auth()->user()->id.'_id_card'. date('Y-m-d H-i-s'). '.' . request()->file('id_card')->getClientOriginalExtension();
$id_card = request()->file('id_card')->storeAs('id-card', $id_card_filename);

$id_card_2_filename = $id . '_'.auth()->user()->id.'_id_card_2'. date('Y-m-d H-i-s'). '.' . request()->file('id_card_2')->extension();
$id_card_2 = request()->file('id_card_2')->storeAs('id-card', $id_card_2_filename, 'local');

$driver_license_filename = $id . '_'.auth()->user()->id.'_driver_license'. date('Y-m-d H-i-s'). '.' . request()->file('driver_license')->extension();
$driver_license = request()->file('driver_license')->storeAs('driver-license', $driver_license_filename, 'local');

$pickup_day = new DateTime($request['dropoff_date']);
$dropoff_day = new DateTime($request['pickup_date']);
$rent_days = $pickup_day->diff($dropoff_day)->days;
$rent_price = $rent_days * $vehicle->price;

$data = [
'vehicle_id' => $id,
'user_id' => auth()->user()->id,
'pickup_date' => $request['pickup_date'],
'pickup_time' => $request['pickup_time'],
'pickup_address' => $request['pickup_location'],
'dropoff_date' => $request['dropoff_date'],
'dropoff_time' => $request['dropoff_time'],
'dropoff_address' => $request['dropoff_location'],
'phone_1' => $request['phone_1'],
'phone_2' => $request['phone_2'],
'address_id' => $request['address_id'],
'address_mlg' => $request['address_mlg'],
'id_card' => $id_card_filename,
'id_card_2' => $id_card_2_filename,
'driver_license' => $driver_license_filename,
'total_price' => $rent_price,
'note' => $request['note'],
'order_status' => 'PENDING',
];

$order = Order::create($data);

return redirect()->route('user-orders');
}

public function getUserOrders()
{
$orders = Order::join('vehicles', 'orders.vehicle_id', '=', 'vehicles.id')
->select("orders.id", "orders.order_status", "orders.created_at", "vehicles.name")
->where('user_id', '=', auth()->user()->id)->get();

return view('order-history', ['orders' => $orders]);
}
}
5 changes: 0 additions & 5 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ public function getUserProfile()
return view('user-profile');
}

public function getUserOrders()
{
return view('order-history');
}

public function updateProfile()
{
$request = request()->input();
Expand Down
21 changes: 21 additions & 0 deletions app/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,25 @@
class Order extends Model
{
use HasFactory;

protected $fillable = [
'user_id',
'vehicle_id',
'pickup_date',
'pickup_time',
'pickup_address',
'dropoff_date',
'dropoff_time',
'dropoff_address',
'total_price',
'order_status',
'phone_1',
'phone_2',
'address_id',
'address_mlg',
'id_card',
'id_card_2',
'driver_license',
'note'
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

use Illuminate\View\Component;

class text-area extends Component
class TextArea extends Component
{

public $value;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
public function __construct($value="")
{
//
$this->value = $value;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'root' => storage_path('app/public'),
'throw' => false,
],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function up()
$table->string('id_card_2');
$table->string('driver_license');
$table->float('total_price', 10, 2);
$table->string('note');
$table->string('note')->nullable();
$table->enum('order_status', ['PENDING', 'REJECTED', 'WAITING_FOR_PAYMENT', 'PAYMENT_DONE', 'CANCELED', 'COMPLETED']);
$table->string('payment_method')->nullable();
$table->string('transaction_id')->nullable();
Expand Down
51 changes: 28 additions & 23 deletions public/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,6 @@ select {
.z-50 {
z-index: 50;
}
.order-1 {
order: 1;
}
.m-3 {
margin: 0.75rem;
}
Expand Down Expand Up @@ -668,6 +665,10 @@ select {
margin-left: 2.5rem;
margin-right: 2.5rem;
}
.my-10 {
margin-top: 2.5rem;
margin-bottom: 2.5rem;
}
.mx-20 {
margin-left: 5rem;
margin-right: 5rem;
Expand All @@ -676,18 +677,14 @@ select {
margin-left: 2rem;
margin-right: 2rem;
}
.my-2 {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
.my-10 {
margin-top: 2.5rem;
margin-bottom: 2.5rem;
}
.my-4 {
margin-top: 1rem;
margin-bottom: 1rem;
}
.my-2 {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
.ml-3 {
margin-left: 0.75rem;
}
Expand Down Expand Up @@ -793,15 +790,18 @@ select {
.ml-8 {
margin-left: 2rem;
}
.mt-5 {
margin-top: 1.25rem;
}
.mt-12 {
margin-top: 3rem;
}
.-mr-2 {
margin-right: -0.5rem;
}
.mt-10 {
margin-top: 2.5rem;
}
.-mr-2 {
margin-right: -0.5rem;
}
.block {
display: block;
}
Expand Down Expand Up @@ -856,6 +856,9 @@ select {
.h-96 {
height: 24rem;
}
.h-full {
height: 100%;
}
.h-40 {
height: 10rem;
}
Expand All @@ -868,18 +871,15 @@ select {
.h-9 {
height: 2.25rem;
}
.h-full {
height: 100%;
.h-4\/5 {
height: 80%;
}
.h-10 {
height: 2.5rem;
}
.h-6 {
height: 1.5rem;
}
.h-4\/5 {
height: 80%;
}
.min-h-screen {
min-height: 100vh;
}
Expand Down Expand Up @@ -1044,9 +1044,6 @@ select {
.grid-cols-1 {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
.grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-rows-2 {
grid-template-rows: repeat(2, minmax(0, 1fr));
}
Expand Down Expand Up @@ -1238,7 +1235,7 @@ select {
fill: currentColor;
}
.fill-white {
fill: #ffffff;
fill: #FFFFFF;
}
.fill-lilac-100 {
fill: #7C7DDC;
Expand Down Expand Up @@ -1483,6 +1480,14 @@ select {
--tw-text-opacity: 1;
color: rgb(169 169 231 / var(--tw-text-opacity));
}
.text-mint-100 {
--tw-text-opacity: 1;
color: rgb(37 222 141 / var(--tw-text-opacity));
}
.text-red {
--tw-text-opacity: 1;
color: rgb(255 80 80 / var(--tw-text-opacity));
}
.underline {
-webkit-text-decoration-line: underline;
text-decoration-line: underline;
Expand Down
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions resources/views/dashboard/vehicles.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<x-base-layout>
<x-base-body>
</x-base-body>
</x-base-layout>
77 changes: 76 additions & 1 deletion resources/views/order-history.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,82 @@
<x-base-layout>
<x-base-body selected="My Order">
<div>
<h1 class="font-bold text-3xl text-lilac-100 mt-24 ml-20">Your order's progress</h1>
<h2 class="font-bold text-xl text-lilac-100 ml-20">Lihat progress dari pengajuan rental yang telah dilakukan</h2>

</div>
@if(count($orders) == 0)
<div class="h-96 mt-20 mb-32 flex justify-center items-center">
<div class="flex flex-col items-center w-full sm:max-w-md px-6 py-4 bg-white shadow-md overflow-hidden sm:rounded-lg">
<p> You haven't rent any vehicle </p>
<div class="flex mt-5">
<a href="{{ url('/find/car') }}">
<x-button filled="true">Find car</x-button>
</a>
<a href="{{ url('/find/motor') }}">
<x-button filled="true">Find motor</x-button>
</a>
</div>
</div>
</div>
@else
@foreach($orders as $order)
<div class="w-full max-w-7xl mx-auto my-4 px-10 py-4 bg-white shadow-md rounded-lg">
<div class="flex flex-wrap justify-between">
<p class="font-bold">{{ $order->name }}</p>
<p>Waktu pengajuan: {{ $order->created_at }}</p>
</div>
<div class="flex mt-2">
@if($order->order_status == 'PENDING')
<svg width="28" height="28" viewBox="0 0 38 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.3958 3.16675C10.6653 3.16675 3.5625 10.2696 3.5625 19.0001C3.5625 27.7306 10.6653 34.8334 19.3958 34.8334C28.1263 34.8334 35.2292 27.7306 35.2292 19.0001C35.2292 10.2696 28.1263 3.16675 19.3958 3.16675ZM28.5 20.5834H17.8125V9.50008H20.9792V17.4167H28.5V20.5834Z" fill="#7C7DDC"/>
</svg>
<p class="ml-2 font-bold text-lilac-100"> Tim Rent.ly sedang meninjau pengajuan Anda. Pembayaran dapat dilakukan setelah pengajuan disetujui. </p>
@elseif($order->order_status == 'REJECTED')
<svg width="28" height="24" viewBox="0 0 43 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_892_988)">
<path d="M0 4.75C0 2.12637 2.12637 0 4.75 0H16.625V9.5C16.625 10.8137 17.6863 11.875 19 11.875H28.5V14.7398C23.0152 16.291 19 21.3305 19 27.3125C19 31.6988 21.1598 35.573 24.4699 37.948C24.2398 37.9777 23.9949 38 23.75 38H4.75C2.12637 38 0 35.8699 0 33.25V4.75ZM19 9.5V0L28.5 9.5H19ZM21.375 27.3125C21.375 21.4121 26.1621 16.625 32.0625 16.625C37.9629 16.625 42.75 21.4121 42.75 27.3125C42.75 33.2129 37.9629 38 32.0625 38C26.1621 38 21.375 33.2129 21.375 27.3125ZM36.4637 24.5887C36.9312 24.1285 36.9312 23.3715 36.4637 22.9113C36.0035 22.4438 35.2465 22.4438 34.7863 22.9113L32.0625 25.6352L29.3387 22.9113C28.8785 22.4438 28.1215 22.4438 27.6613 22.9113C27.1938 23.3715 27.1938 24.1285 27.6613 24.5887L30.3852 27.3125L27.6613 30.0363C27.1938 30.4965 27.1938 31.2535 27.6613 31.7137C28.1215 32.1812 28.8785 32.1812 29.3387 31.7137L32.0625 28.9898L34.7863 31.7137C35.2465 32.1812 36.0035 32.1812 36.4637 31.7137C36.9312 31.2535 36.9312 30.4965 36.4637 30.0363L33.7398 27.3125L36.4637 24.5887Z" fill="#FF5050"/>
</g>
<defs>
<clipPath id="clip0_892_988">
<rect width="42.75" height="38" fill="white"/>
</clipPath>
</defs>
</svg>
<p class="ml-2 font-bold text-red"> Pengajuan rental ditolak. Mohon periksa kembali data dan dokumen yang anda input. </p>
@elseif($order->order_status == 'WAITING_FOR_PAYMENT')
<svg width="28" height="24" viewBox="0 0 43 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_892_986)">
<path d="M0 4.75C0 2.12637 2.12637 0 4.75 0H16.625V9.5C16.625 10.8137 17.6863 11.875 19 11.875H28.5V14.7398C23.0152 16.291 19 21.3305 19 27.3125C19 31.6988 21.1598 35.573 24.4699 37.948C24.2398 37.9777 23.9949 38 23.75 38H4.75C2.12637 38 0 35.8699 0 33.25V4.75ZM19 9.5V0L28.5 9.5H19ZM42.75 27.3125C42.75 33.2129 37.9629 38 32.0625 38C26.1621 38 21.375 33.2129 21.375 27.3125C21.375 21.4121 26.1621 16.625 32.0625 16.625C37.9629 16.625 42.75 21.4121 42.75 27.3125ZM35.3801 24.0988L30.875 28.6039L28.7449 26.4738C28.2848 26.0063 27.5277 26.0063 27.0676 26.4738C26.6 26.934 26.6 27.691 27.0676 28.1512L30.0363 31.1199C30.4965 31.5875 31.2535 31.5875 31.7137 31.1199L37.0574 25.7762C37.525 25.316 37.525 24.559 37.0574 24.0988C36.5973 23.6313 35.8402 23.6313 35.3801 24.0988Z" fill="#25DE8D"/>
</g>
<defs>
<clipPath id="clip0_892_986">
<rect width="42.75" height="38" fill="white"/>
</clipPath>
</defs>
</svg>
<p class="ml-2 font-bold text-mint-100"> Pengajuan rental telah disetujui. Silahkan lakukan pembayaran. </p>
@elseif($order->order_status == 'PAYMENT_DONE')
<svg width="28" height="28" viewBox="0 0 38 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.0001 3.1665C10.2696 3.1665 3.16675 10.2693 3.16675 18.9998C3.16675 27.7303 10.2696 34.8332 19.0001 34.8332C27.7306 34.8332 34.8334 27.7303 34.8334 18.9998C34.8334 10.2693 27.7306 3.1665 19.0001 3.1665ZM15.835 25.9871L9.95608 20.1208L12.1917 17.8788L15.8318 21.5126L24.214 13.1304L26.4528 15.3693L15.835 25.9871Z" fill="#25DE8D"/>
</svg>
<p class="ml-2 font-bold text-mint-100"> Pembayaran telah diterima. Kendaraan dapat dirental pada waktu yang telah ditentukan. </p>
@elseif($order->order_status == 'CANCELED')
<svg width="28" height="28" viewBox="0 0 38 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.0001 3.1665C10.2442 3.1665 3.16675 10.244 3.16675 18.9998C3.16675 27.7557 10.2442 34.8332 19.0001 34.8332C27.7559 34.8332 34.8334 27.7557 34.8334 18.9998C34.8334 10.244 27.7559 3.1665 19.0001 3.1665ZM25.8084 25.8082C25.6619 25.955 25.4879 26.0714 25.2964 26.1509C25.1049 26.2303 24.8995 26.2712 24.6922 26.2712C24.4848 26.2712 24.2795 26.2303 24.0879 26.1509C23.8964 26.0714 23.7224 25.955 23.5759 25.8082L19.0001 21.2323L14.4242 25.8082C14.1282 26.1042 13.7267 26.2705 13.308 26.2705C12.8893 26.2705 12.4878 26.1042 12.1917 25.8082C11.8957 25.5121 11.7294 25.1106 11.7294 24.6919C11.7294 24.4846 11.7702 24.2793 11.8495 24.0878C11.9289 23.8963 12.0452 23.7223 12.1917 23.5757L16.7676 18.9998L12.1917 14.424C11.8957 14.128 11.7294 13.7264 11.7294 13.3078C11.7294 12.8891 11.8957 12.4876 12.1917 12.1915C12.4878 11.8955 12.8893 11.7291 13.308 11.7291C13.7267 11.7291 14.1282 11.8955 14.4242 12.1915L19.0001 16.7673L23.5759 12.1915C23.7225 12.0449 23.8965 11.9286 24.0881 11.8493C24.2796 11.77 24.4849 11.7291 24.6922 11.7291C24.8995 11.7291 25.1047 11.77 25.2963 11.8493C25.4878 11.9286 25.6618 12.0449 25.8084 12.1915C25.955 12.3381 26.0713 12.5121 26.1506 12.7036C26.2299 12.8952 26.2708 13.1004 26.2708 13.3078C26.2708 13.5151 26.2299 13.7203 26.1506 13.9119C26.0713 14.1034 25.955 14.2774 25.8084 14.424L21.2326 18.9998L25.8084 23.5757C26.4101 24.1773 26.4101 25.1907 25.8084 25.8082Z" fill="#FF5050"/>
</svg>
<p class="ml-2 font-bold text-red"> Pengajuan dibatalkan. </p>
@elseif($order->order_status == 'COMPLETED')
<svg width="28" height="28" viewBox="0 0 38 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.0001 3.1665C10.2601 3.1665 3.16675 10.2598 3.16675 18.9998C3.16675 27.7398 10.2601 34.8332 19.0001 34.8332C27.7401 34.8332 34.8334 27.7398 34.8334 18.9998C34.8334 10.2598 27.7401 3.1665 19.0001 3.1665ZM14.7092 25.7923L9.02508 20.1082C8.87849 19.9616 8.76221 19.7876 8.68288 19.596C8.60355 19.4045 8.56272 19.1992 8.56272 18.9919C8.56272 18.7846 8.60355 18.5793 8.68288 18.3878C8.76221 18.1963 8.87849 18.0223 9.02508 17.8757C9.17167 17.7291 9.34569 17.6128 9.53722 17.5335C9.72875 17.4541 9.93403 17.4133 10.1413 17.4133C10.3486 17.4133 10.5539 17.4541 10.7454 17.5335C10.937 17.6128 11.111 17.7291 11.2576 17.8757L15.8334 22.4357L26.7267 11.5423C27.0228 11.2463 27.4243 11.08 27.843 11.08C28.2617 11.08 28.6632 11.2463 28.9592 11.5423C29.2553 11.8384 29.4216 12.2399 29.4216 12.6586C29.4216 13.0773 29.2553 13.4788 28.9592 13.7748L16.9417 25.7923C16.7953 25.9391 16.6213 26.0556 16.4297 26.135C16.2382 26.2145 16.0329 26.2554 15.8255 26.2554C15.6181 26.2554 15.4128 26.2145 15.2213 26.135C15.0297 26.0556 14.8557 25.9391 14.7092 25.7923Z" fill="#66E9AF"/>
</svg>
<p class="ml-2 font-bold text-mint-100"> Rent process completed </p>
@endif
</div>
<div class="flex justify-end">
<x-button filled=true>View details</x-button>
</div>
</div>
@endforeach
@endif
</x-base-body>
</x-base-layout>
Loading

0 comments on commit 0ac880c

Please sign in to comment.