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') +
+
+
+

@yield('title')

+

@lang('admin.delete_album_confirm', ['name' => $album->name])

+
+ @lang('admin.delete_album_warning') +
+
+ {!! Form::open(['url' => route('albums.destroy', ['id' => $album->id]), 'method' => 'DELETE']) !!} + @lang('forms.cancel_action') + {!! Form::submit(trans('forms.delete_action'), ['class' => 'btn btn-danger']) !!} + {!! Form::close() !!} +
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/admin/list_albums.blade.php b/resources/views/admin/list_albums.blade.php index 63b3f7c..a221b57 100644 --- a/resources/views/admin/list_albums.blade.php +++ b/resources/views/admin/list_albums.blade.php @@ -5,25 +5,35 @@
- - - - - - - - - @foreach ($albums as $album) - - - - - @endforeach - -
@lang('admin.list_albums_name_column')
{{ $album->name }} - @lang('forms.edit_action') - @lang('forms.delete_action') -
+ @if (count($albums) == 0) +
+

@lang('admin.no_albums_title')

+

@lang('admin.no_albums_text')

+

+ @lang('admin.create_album') +

+
+ @else + + + + + + + + + @foreach ($albums as $album) + + + + + @endforeach + +
@lang('admin.list_albums_name_column')
{{ $album->name }} + @lang('forms.edit_action') + @lang('forms.delete_action') +
+ @endif
diff --git a/resources/views/partials/navbar.blade.php b/resources/views/partials/navbar.blade.php index 5307edb..bf96767 100644 --- a/resources/views/partials/navbar.blade.php +++ b/resources/views/partials/navbar.blade.php @@ -35,7 +35,7 @@ @endcan