Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow querying terms with specified taxonomy/taxonomies#444

Open
Dartui wants to merge 1 commit intocorcel:3.0from
Dartui:term_scope_where_taxonomy
Open

Allow querying terms with specified taxonomy/taxonomies#444
Dartui wants to merge 1 commit intocorcel:3.0from
Dartui:term_scope_where_taxonomy

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.

2 participants