diff options
author | Frankie B <git@diskfloppy.me> | 2023-07-16 21:02:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 21:02:51 +0100 |
commit | 7c16dc53b55aa50d6c9ac0bdea2f51fbbf2b20b0 (patch) | |
tree | d81c7682b4696d4182ab375d64fa69c4ff755647 /routes/web.php | |
parent | 691d0d933d9c2d9289fa01c7153371e45998ac53 (diff) |
feat: site admin (#8)
Diffstat (limited to 'routes/web.php')
-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!'); +}); |