Skip to content

Commit f064018

Browse files
Add finder and getter trait
1 parent ef57303 commit f064018

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Traits/ModelFinder.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php namespace Lecturize\Taxonomies\Traits;
2+
3+
use Lecturize\Taxonomies\Models\Taxonomy;
4+
use Lecturize\Taxonomies\Models\Term;
5+
6+
/**
7+
* Class ModelFinder
8+
* @package Lecturize\Taxonomies\Traits
9+
*/
10+
trait ModelFinder
11+
{
12+
/**
13+
* Find term.
14+
*
15+
* @param string $slug
16+
* @return Term
17+
*/
18+
public function findTerm($slug): Term
19+
{
20+
return Term::whereSlug($slug)->first();
21+
}
22+
23+
/**
24+
* Find taxonomy by term.
25+
*
26+
* @param string $term_id
27+
* @param string $taxonomy
28+
* @return Taxonomy
29+
*/
30+
public function findTaxonomyByTerm($term_id, $taxonomy): Taxonomy
31+
{
32+
return Taxonomy::where('term_id', $term_id)
33+
->where('taxonomy', $taxonomy)
34+
->first();
35+
}
36+
}

src/Traits/ModelGetter.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php namespace Lecturize\Taxonomies\Traits;
2+
3+
/**
4+
* Class ModelGetter
5+
* @package Lecturize\Taxonomies\Traits
6+
*/
7+
trait ModelGetter
8+
{
9+
// @todo
10+
}

0 commit comments

Comments
 (0)