diff options
Diffstat (limited to 'routes')
-rw-r--r-- | routes/web.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/routes/web.php b/routes/web.php index 6185449..7284bc3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -40,4 +40,46 @@ Route::post('/guestbook', 'App\Http\Controllers\GuestbookController@guestbookpos ->name('guestbookPost') ->middleware('rate_limit'); +Route::get('/admin', function () { + if (!auth()->check()) { + return view('errors.no-auth'); + } + return view('pages.admin.index'); +}); + +Route::get('/admin/guestbook', function () { + if (!auth()->check()) { + return view('errors.no-auth'); + } + return view('pages.admin.guestbook'); +}); + +Route::get('/admin/guestbook/delete', function () { + if (!auth()->check()) { + return view('errors.no-auth'); + } + + $id = request()->input('id'); + $entry = DB::table('guestbook_entries')->find($id); + + if ($entry) { + // Render a confirmation view + return View::make('pages.admin.guestbook-del-confirm', compact('entry')); + } else { + return view('errors.generic-error') + ->with('error', "Entry not found") + ->with('description', "The specified entry does not exist!"); + } +}); + +Route::post('/admin/guestbook/delete', function () { + if (!auth()->check()) { + return view('errors.no-auth'); + } + + $id = request()->input('id'); + DB::table('guestbook_entries')->where('id', $id)->delete(); + + return back()->with('success', 'Entry deleted successfully!'); +}); |