diff --git a/app/Album.php b/app/Album.php index 62ccca9..a5202ec 100644 --- a/app/Album.php +++ b/app/Album.php @@ -200,6 +200,7 @@ class Album extends Model if (is_null($this->url_path)) { $this->generateUrlPath(); + $this->save(); } return route('viewAlbum', $this->url_path); diff --git a/app/Http/Controllers/Admin/AlbumController.php b/app/Http/Controllers/Admin/AlbumController.php index 82e36b8..aa6b101 100644 --- a/app/Http/Controllers/Admin/AlbumController.php +++ b/app/Http/Controllers/Admin/AlbumController.php @@ -408,6 +408,7 @@ class AlbumController extends Controller $album->user_id = Auth::user()->id; $album->generateAlias(); + $album->generateUrlPath(); $album->save(); // Link all default permissions to anonymous users (if a public album) @@ -440,6 +441,8 @@ class AlbumController extends Controller $this->authorizeAccessToAdminPanel('admin:manage-albums'); $album = $this->loadAlbum($id); + $currentParentID = $album->parent_album_id; + $album->fill($request->only(['name', 'description', 'parent_album_id'])); if (strlen($album->parent_album_id) == 0) @@ -456,6 +459,12 @@ class AlbumController extends Controller } } + // Re-generate the URL path to ensure it's correct if the parent has changed + if ($currentParentID != $album->parent_album_id) + { + $album->generateUrlPath(); + } + $album->save(); $request->session()->flash('success', trans('admin.album_saved_successfully', ['name' => $album->name])); diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index a278c96..7f3e1d3 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -75,6 +75,7 @@ return [ 'delete_user_warning' => 'This is a permanent action that cannot be reversed!', 'edit_album' => 'Edit photo album: :album_name', 'edit_album_action' => 'Edit album details', + 'edit_album_change_parent_warning' => 'Changing this album\'s parent will change the address used to access this album. This may break any bookmarks or links used by your visitors or search engines.', 'edit_album_intro' => 'Photo albums contain individual photographs in the same way as a physical photo album or memory book.', 'edit_album_intro2' => 'Complete the form below to edit the properties of the album: :album_name.', 'edit_group_intro' => 'You can use the form below to edit the above group. Changes take effect immediately.', diff --git a/resources/views/themes/base/admin/edit_album.blade.php b/resources/views/themes/base/admin/edit_album.blade.php index 1bf1d2d..f95b938 100644 --- a/resources/views/themes/base/admin/edit_album.blade.php +++ b/resources/views/themes/base/admin/edit_album.blade.php @@ -54,6 +54,10 @@ +
+ @lang('admin.edit_album_change_parent_warning') +
+
@lang('forms.cancel_action')