Skip to content

Commit

Permalink
Add finder and getter trait
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderPoellmann committed Feb 6, 2021
1 parent ef57303 commit f064018
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Traits/ModelFinder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php namespace Lecturize\Taxonomies\Traits;

use Lecturize\Taxonomies\Models\Taxonomy;
use Lecturize\Taxonomies\Models\Term;

/**
* Class ModelFinder
* @package Lecturize\Taxonomies\Traits
*/
trait ModelFinder
{
/**
* Find term.
*
* @param string $slug
* @return Term
*/
public function findTerm($slug): Term
{
return Term::whereSlug($slug)->first();
}

/**
* Find taxonomy by term.
*
* @param string $term_id
* @param string $taxonomy
* @return Taxonomy
*/
public function findTaxonomyByTerm($term_id, $taxonomy): Taxonomy
{
return Taxonomy::where('term_id', $term_id)
->where('taxonomy', $taxonomy)
->first();
}
}
10 changes: 10 additions & 0 deletions src/Traits/ModelGetter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php namespace Lecturize\Taxonomies\Traits;

/**
* Class ModelGetter
* @package Lecturize\Taxonomies\Traits
*/
trait ModelGetter
{
// @todo
}

0 comments on commit f064018

Please sign in to comment.