-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3de3cb
commit 67976bf
Showing
11 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
'afterwards' => 'Danach', | ||
'background_color' => 'Hintergrund-Farbe', | ||
'description' => 'Beschreibung', | ||
'go_where_moved_to' => 'Gehe dorthin, wohin bewegt wurde', | ||
'published' => 'Veröffentlicht', | ||
'stay_here' => 'Bleibe hier', | ||
'subtitle' => 'Untertitel', | ||
'title' => 'Titel', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
<?php | ||
|
||
return [ | ||
'afterwards' => 'afterwards', | ||
'background_color' => 'background color', | ||
'description' => 'description', | ||
'go_where_moved_to' => 'go where they have been moved to', | ||
'published' => 'published', | ||
'stay_here' => 'stay here', | ||
'subtitle' => 'subtitle', | ||
'title' => 'title', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
namespace Kraenkvisuell\NovaCmsPortfolio\Nova\Actions; | ||
|
||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\Cache; | ||
use Kraenkvisuell\NovaCmsPortfolio\Models\Slideshow; | ||
use Laravel\Nova\Actions\Action; | ||
use Laravel\Nova\Fields\ActionFields; | ||
use Laravel\Nova\Fields\Select; | ||
|
||
class MoveToSlideshow extends Action | ||
{ | ||
public function name() | ||
{ | ||
return ucfirst(__( | ||
'nova-cms-portfolio::works.move_to_different_project', | ||
[ | ||
'attribute' => config('nova-cms-portfolio.custom_slideshow_label') | ||
?: ucfirst(__('nova-cms-portfolio::slideshows.slideshow')), | ||
] | ||
)); | ||
} | ||
|
||
public function handle(ActionFields $fields, Collection $works) | ||
{ | ||
$oldSlideshowId = $works->first()->slideshow_id; | ||
|
||
foreach ($works as $work) { | ||
$work->slideshow_id = $fields->slideshow_id; | ||
$work->sort_order += 1000; | ||
$work->save(); | ||
} | ||
|
||
Slideshow::find($oldSlideshowId)->refreshWorksOrder(); | ||
Slideshow::find($fields->slideshow_id)->refreshWorksOrder(); | ||
|
||
if ($fields->afterwards == 'go_to_other_slideshow') { | ||
return Action::push('/resources/slideshows/'.$fields->slideshow_id); | ||
} | ||
} | ||
|
||
public function fields() | ||
{ | ||
$slideshows = $this->getSlideshows(); | ||
|
||
return [ | ||
Select::make( | ||
( | ||
config('nova-cms-portfolio.custom_slideshow_label') | ||
?: ucfirst(__('nova-cms-portfolio::slideshows.slideshow')) | ||
), | ||
'slideshow_id' | ||
) | ||
->options($slideshows) | ||
->required() | ||
->rules('required'), | ||
|
||
Select::make( | ||
ucfirst(__('nova-cms-portfolio::portfolio.afterwards')), | ||
'afterwards' | ||
) | ||
->required() | ||
->rules('required') | ||
->options([ | ||
'go_to_other_slideshow' => __( | ||
'nova-cms-portfolio::portfolio.go_where_moved_to' | ||
), | ||
'stay_on_this_slideshow' => __( | ||
'nova-cms-portfolio::portfolio.stay_here' | ||
), | ||
|
||
]) | ||
->default('go_to_other_slideshow'), | ||
]; | ||
} | ||
|
||
protected function getSlideshows() | ||
{ | ||
return Cache::remember( | ||
'nova.artist.projects.'.request()->input('viaResourceId'), | ||
now()->addSeconds(5), | ||
function () { | ||
$currentSlideshow = Slideshow::where('id', request()->input('viaResourceId')) | ||
->with([ | ||
'artist.slideshows', | ||
'artist.categories', | ||
'categories', | ||
]) | ||
->first(); | ||
|
||
$slideshows = []; | ||
|
||
foreach ($currentSlideshow->artist->categories as $category) { | ||
foreach ($currentSlideshow->artist->slideshows as $slideshow) { | ||
if ( | ||
$currentSlideshow->id != $slideshow->id | ||
&& $slideshow->categories->firstWhere('id', $category->id) | ||
) { | ||
$slideshows[$slideshow->id] = $category->title.': '.$slideshow->title; | ||
} | ||
} | ||
} | ||
|
||
return $slideshows; | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters