diff --git a/app/Http/Controllers/Admin/AlbumController.php b/app/Http/Controllers/Admin/AlbumController.php index ae64d02..6e01ad7 100644 --- a/app/Http/Controllers/Admin/AlbumController.php +++ b/app/Http/Controllers/Admin/AlbumController.php @@ -38,11 +38,17 @@ class AlbumController extends Controller return view('admin.create_album'); } - public function delete() + public function delete($id) { $this->authorize('admin-access'); - return view('admin.delete_album'); + $album = Album::all()->where('id', intval($id))->first(); + if (is_null($album)) + { + App::abort(404); + } + + return view('admin.delete_album', ['album' => $album]); } /** @@ -112,5 +118,14 @@ class AlbumController extends Controller public function destroy($id) { $this->authorize('admin-access'); + + $album = Album::all()->where('id', intval($id))->first(); + if (is_null($album)) + { + App::abort(404); + } + + $album->delete(); + return redirect(route('albums.index')); } } \ No newline at end of file diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 7ac2781..d59c792 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -5,7 +5,12 @@ return [ 'create_album_intro' => 'Photo albums contain individual photographs together in the same way as a physical photo album or memory book.', 'create_album_intro2' => 'Complete the form below to create a photo album.', 'create_album_link' => 'Create album', + 'delete_album' => 'Delete album :name', + 'delete_album_confirm' => 'Are you sure you want to permanently delete this album and all its contents?', + 'delete_album_warning' => 'This is a permanent action that cannot be undone!', 'list_albums_name_column' => 'Album name', + 'no_albums_text' => 'You have no photo albums yet. Click the button below to create one.', + 'no_albums_title' => 'No Photo Albums', 'stats_albums' => 'album|albums', 'stats_panel' => 'Statistics' ]; \ No newline at end of file diff --git a/resources/views/admin/delete_album.blade.php b/resources/views/admin/delete_album.blade.php new file mode 100644 index 0000000..9046bea --- /dev/null +++ b/resources/views/admin/delete_album.blade.php @@ -0,0 +1,22 @@ +@extends('layouts.app') +@section('title', trans('admin.delete_album', ['name' => $album->name])) + +@section('content') +
@lang('admin.delete_album_confirm', ['name' => $album->name])
+@lang('admin.list_albums_name_column') | -- |
---|---|
{{ $album->name }} | -- @lang('forms.edit_action') - @lang('forms.delete_action') - | -
@lang('admin.no_albums_text')
+ +@lang('admin.list_albums_name_column') | ++ |
---|---|
{{ $album->name }} | ++ @lang('forms.edit_action') + @lang('forms.delete_action') + | +