We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a resource called Product and it has a relationship with another named Section.
Product
Section
Section is multiple select options of Product whenever I create or update Product.
Now, Whenever I replicate Product I want it also to replicate Section (auto select Section like the one replicated).
I have a workaround like this. It seems to work but I'm not so sure.
Does Nova or this package support a way to do it?
Thanks for your help!
public function fields(NovaRequest $request): array { return [ //.. $this->sections(), ]; }
public function replicate() { $productId = request()->get('fromResourceId'); $sections = \App\Models\ServiceSection::whereHas('products', function(Builder $q) use ($productId) { $q->where('product_id', $productId); })->get(); if (!empty($sections)){ self::$isReplicate = true; $sections->map(function ($section) { self::$sectionOptions[] = [$section->id]; }); } return parent::replicate(); }
/** * @throws Exception */ protected function sections(): Multiselect { $sections = MultiTagField::make(__('Service Sections'), 'sections') ->api('/api/sections-by-service', ServiceSection::class) ->belongsToMany(ServiceSection::class, false) ->hideFromIndex(); if (self::$isReplicate){ $sections->withMeta(['value' => self::$sectionOptions]); } return $sections; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a resource called
Product
and it has a relationship with another namedSection
.Section
is multiple select options of Product whenever I create or update Product.Now, Whenever I replicate
Product
I want it also to replicateSection
(auto select Section like the one replicated).I have a workaround like this. It seems to work but I'm not so sure.
Does Nova or this package support a way to do it?
Thanks for your help!
The text was updated successfully, but these errors were encountered: