From 81f85b0d10921523619629f200054b588d2a5566 Mon Sep 17 00:00:00 2001 From: Benjamin Takats Date: Sun, 22 Jan 2023 12:50:01 +0100 Subject: [PATCH] AttachLibraryItemToLibrary --- .../Actions/AttachLibraryItemToLibrary.php | 51 +++++++++++++++++++ app/Nova/LibraryItem.php | 2 + 2 files changed, 53 insertions(+) create mode 100644 app/Nova/Actions/AttachLibraryItemToLibrary.php diff --git a/app/Nova/Actions/AttachLibraryItemToLibrary.php b/app/Nova/Actions/AttachLibraryItemToLibrary.php new file mode 100644 index 00000000..f04ffcb1 --- /dev/null +++ b/app/Nova/Actions/AttachLibraryItemToLibrary.php @@ -0,0 +1,51 @@ +libraries() + ->attach($fields->library); + } + } + + /** + * Get the fields available on the action. + * + * @param \Laravel\Nova\Http\Requests\NovaRequest $request + * + * @return array + */ + public function fields(NovaRequest $request) + { + $libraries = Library::query() + ->pluck('name', 'id'); + + return [ + Select::make('Library') + ->options($libraries), + ]; + } +} diff --git a/app/Nova/LibraryItem.php b/app/Nova/LibraryItem.php index 3955250b..7ead3e41 100644 --- a/app/Nova/LibraryItem.php +++ b/app/Nova/LibraryItem.php @@ -4,6 +4,7 @@ namespace App\Nova; use App\Enums\LibraryItemType; use App\Notifications\ModelCreatedNotification; +use App\Nova\Actions\AttachLibraryItemToLibrary; use App\Nova\Actions\SetStatusAction; use App\Nova\Filters\LibraryItemWithoutLibrary; use Ebess\AdvancedNovaMediaLibrary\Fields\Files; @@ -225,6 +226,7 @@ class LibraryItem extends Resource public function actions(Request $request) { return [ + new AttachLibraryItemToLibrary(), new SetStatusAction(), ]; }