feat: site admin (#8)
This commit is contained in:
parent
c5d62dc343
commit
2a11cff663
15 changed files with 1378 additions and 52 deletions
|
@ -40,4 +40,46 @@
|
|||
->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!');
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue