Corcel\TermTaxonomyBuilder::slug PHP Method

slug() public method

Get a term taxonomy by specific slug
public slug ( $slug = null ) : TermTaxonomyBuilder
return TermTaxonomyBuilder
    public function slug($slug = null)
    {
        if (!is_null($slug) and !empty($slug)) {
            // set this slug to be used in with callback
            $this->slug = $slug;
            // exception to filter on specific slug
            $exception = function ($query) {
                $query->where('slug', '=', $this->slug);
            };
            // load term to filter
            return $this->whereHas('term', $exception);
        }
        return $this;
    }