Works for friday & saturday

This commit is contained in:
Ludovic CANDELLIER
2022-05-29 00:46:04 +02:00
parent 352b109e87
commit 5b74c93b2e
44 changed files with 2023 additions and 79 deletions

View File

@@ -89,6 +89,11 @@ class Article extends Model implements HasMedia
return $query->where($this->table . '.name', 'LIKE', "%${str}%");
}
public function scopeSearch($query, $str)
{
return $query->where($this->table . '.name', 'LIKE', "%${str}%");
}
public function scopeByArticleNature($query, $id)
{
return $query->where($this->table . '.article_nature_id', $id);
@@ -140,6 +145,15 @@ class Article extends Model implements HasMedia
}) : $query;
}
public function scopeByTagsSelected($query, $tags)
{
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
foreach ($tags as $tag) {
$query->where('id', $tag);
}
}) : $query;
}
public function scopeWithOffers($query)
{
return $query->has('offers');