Skip to content
New issue

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

Allow querying terms with specified taxonomy/taxonomies #444

Open
wants to merge 1 commit into
base: 3.0
Choose a base branch
from
Open

Allow querying terms with specified taxonomy/taxonomies #444

wants to merge 1 commit into from

Conversation

Dartui
Copy link
Contributor

@Dartui Dartui commented Feb 2, 2019

Simple helper for querying terms in specified taxonomy/taxonomies. Usage:

Term::whereTaxonomy('foo')->get();
Term::whereTaxonomies(['foo', 'bar'])->get();

Of course it can be chained to get only one term in specified taxonomy:

Term::whereTaxonomy('categories')->where('slug', 'projects')->first();

Without this code similar or same query could be generated in this way:

 // second where is collection method, not database query
Taxonomy::where('taxonomy', 'categories')->get()
    ->pluck('term')->where('slug', 'projects')->first();

// code copied from this PR
Term::whereHas('taxonomy', function ($query) {
    $query->whereIn('taxonomy', 'category');
})->where('slug', 'projects')->first();

@jgrossi jgrossi changed the base branch from 2.7 to 3.0 January 27, 2020 21:19
@jgrossi
Copy link
Member

jgrossi commented Jan 27, 2020

@Dartui can you update this PR just to rerun Travis CI please? changed the base branch to 3.0 and would like to double check if tests are passing before merging. thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants