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
UseCase: only pre-defined tags should be selectable no dynamic creation of tags should be possible as with https://novapackages.com/packages/spatie/nova-tags-field
// define type to select from $tagType = 'myType'; //(...) Multiselect::make(__("Tags"), 'tags') ->options(function () use ($tagType) { $query = resolve(config('tags.tag_model', Tag::class))->query(); $filter_containing = null; $filter_type = $tagType; $limit = null; if ($filter_containing) { $query->containing($filter_containing); } if ($filter_type) { $query->where('type', $filter_type); } if ($limit) { $query->limit($limit); } $sorted = $query->get()->sortBy(function (Tag $tag) { return strtolower($tag->name); })->values(); $tags = $sorted->mapWithKeys(function (Tag $tag, $key) { return [$tag->name => $tag->name]; }); return $tags; }) ->resolveUsing(function ($tags) { return $tags->pluck('name'); }) ->fillUsing(function ($request, $model, $attribute, $requestAttribute) use ($tagType) { $requestValue = $request[$requestAttribute]; $tagNames = array_values($requestValue ?? []); $tagNames = array_filter($tagNames); // remove empty values $class = get_class($model); $class::saved(function ($model) use ($tagNames) { $model->syncTagsWithType($tagNames, $tagType ?? null); }); }) ->placeholder(__('Add Tags')) // Placeholder text
The text was updated successfully, but these errors were encountered:
No branches or pull requests
UseCase: only pre-defined tags should be selectable no dynamic creation of tags should be possible as with https://novapackages.com/packages/spatie/nova-tags-field
The text was updated successfully, but these errors were encountered: