Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Taxonomies Laravel Package

myerscode/laravel-taxonomies

View on GitHub
Deep Wiki
Context7

Taggable Model

Once your Model uses the HasTaxonomyTrait you can start tagging it.

Adding terms to models

Add a basic term (with no taxonomy)

$post->addTerm('Hello')

You can associate terms with a given Taxonomy to the model, by passing in the Taxonomy name, slug, id or a Taxonomy model.

// by  name
$post->addTerm('term a', 'Foo Bar');

// by slug
$post->addTerm('term b', 'foo-bar');

// by id
$post->addTerm('term 1', 7);

// by model
$taxonomy = Taxonomy::findOrNew('Foo Bar');
$post->addTerm('term abc', $taxonomy);

Finding models with terms

withAnyTerms

The hasAnyTerms helper method will return models that have one or more of the given terms attached to them.

// find models that have one or more terms
Post::hasAnyTerms(['term a', 'term b']);

// find models that have one or more terms in a given taxonomy
Post::hasAnyTerms(['term 1', 'term 2'], 'foo-bar');

It can be used as a Query Builder scope by using $builder->hasAnyTerms(['term a', 'term b']).

hasAllTerms

The hasAllTerms helper method will return models that have all of the given terms attached to them.

// find models that have all terms
Post::hasAllTerms(['term a', 'tag b']);

// find models that have all terms in a given taxonomy
Post::hasAllTerms(['term 1', 'term 2'], 'foo-bar');

It can be used as a Query Builder scope by using $builder->hasAllTerms(['term 1', 'term 2'], 'foo-bar').

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui