This commit is contained in:
ludo
2025-01-03 03:46:45 +01:00
parent b3fbfc38e7
commit befaa40b48
44 changed files with 442 additions and 165 deletions

View File

@@ -47,4 +47,18 @@ class Specie extends Model implements HasMedia
{
return $query->where($this->table.'.name', $name);
}
public function scopeByTag($query, $tagId)
{
return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) {
$query->byId($tagId);
}) : $query;
}
public function scopeByTags($query, $tags)
{
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
$query->byIds($tags);
}) : $query;
}
}