public function getTypeAttribute() { return $this->attributes['type'] ?: HasTags::getDefaultTagType(); }
/** * Get a tag from it's url. * * @param string $url * @param string $locale * * @return \App\Models\Tag */ public function findByUrl($url, $type = null, $locale = null) { $type = $type ?: HasTags::getDefaultTagType(); $locale = $locale ?: content_locale(); return $this->model->where('type', $type)->whereHas('translations', function ($query) use($url, $locale) { $query->where('url', $url)->where('locale', $locale); })->first(); }