Browse Source

delete bookings

main
Holly McFarland 4 months ago
parent
commit
47335af32c
3 changed files with 12 additions and 1 deletions
  1. +10
    -0
      app/Http/Controllers/BookingsController.php
  2. +1
    -1
      resources/views/bookings.blade.php
  3. +1
    -0
      routes/web.php

+ 10
- 0
app/Http/Controllers/BookingsController.php View File

@ -34,6 +34,11 @@ class BookingsController extends Controller
}
public function submit(Request $request) {
$request->validate([
'guest_name' => 'required',
'date' => 'required',
]);
Booking::insert([
'room_id' => $request->room,
'guest_name' => $request->guest_name,
@ -41,4 +46,9 @@ class BookingsController extends Controller
]);
return redirect('bookings');
}
public function delete($id) {
Booking::find($id)->delete();
return redirect('bookings');
}
}

+ 1
- 1
resources/views/bookings.blade.php View File

@ -40,7 +40,7 @@
</tr>
@foreach ($records as $record)
<tr>
<td>Delete</td>
<td><a href="{{ route('deletebooking', ['id' => $record['id']]) }}">Delete</a></td>
<td>{{ $record['room_number'] }}</td>
<td>{{ $record['room_name'] }}</td>
<td>{{ $record['guest_name'] }}</td>


+ 1
- 0
routes/web.php View File

@ -27,5 +27,6 @@ Route::post('/rooms/submitEdit', [RoomsController::class, 'submitEdit'])->name('
Route::get('/bookings', [BookingsController::class, 'index'])->name('bookings');
Route::post('/bookings/submit', [BookingsController::class, 'submit'])->name('submitbooking');
Route::get('/bookings/delete/{id}', [BookingsController::class, 'delete'])->name('deletebooking');
Route::get('/about', [AboutController::class, 'index'])->name('about');

Loading…
Cancel
Save