Skip to content

Commit

Permalink
added validation
Browse files Browse the repository at this point in the history
  • Loading branch information
haziq-danial committed Jan 23, 2022
1 parent 300b47b commit fad622f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 439 deletions.
10 changes: 8 additions & 2 deletions app/Http/Controllers/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,22 @@ public function view()

public function book(Request $request)
{
// dd($request);
$booking_exists = Booking::where('user_id', $request->user_id)
->where('status', BookingStatus::ONGOING)
->first();
// dd(!is_null($booking_exists));

$request->validate([
'user_id' => ['required'],
'start_timme' => ['required'],
'parking_duration' => ['required'],
'parking_slot' => ['required']
]);

if (!is_null($booking_exists)) {
return redirect()->back()->with('message', 'Booking already existed');
}


$booking = Booking::create([
'user_id' => $request->user_id,
'date_booking' => $request->date_booking,
Expand Down
8 changes: 8 additions & 0 deletions resources/views/auth/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
</head>
<body class="hold-transition login-page">
<div class="login-box">
@if ($errors->any())
@foreach($errors->all() as $error)
<div class="alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>
<p>{{ $error }}</p>
</div>
@endforeach
@endif
<!-- /.login-logo -->
<div class="card card-outline card-primary">
<div class="card-header text-center">
Expand Down
Loading

0 comments on commit fad622f

Please sign in to comment.