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;
}