[WIP] begin of new display for article, shelves

This commit is contained in:
Ludovic CANDELLIER
2022-06-13 23:29:05 +02:00
parent e31978b1e3
commit b37321daf8
13 changed files with 163 additions and 98 deletions

View File

@@ -16,6 +16,9 @@ use Staudenmeir\EloquentHasManyDeep\HasRelationships;
use App\Traits\Model\HasComments;
use App\Traits\Model\Imageable;
use App\Models\Botanic\Variety;
use App\Models\Botanic\Specie;
class Article extends Model implements HasMedia
{
use Categorizable, EloquentJoin, HasComments, HasRelationships, Imageable, Powerjoins, Taggable, SoftDeletes, UserStamps;
@@ -99,6 +102,11 @@ class Article extends Model implements HasMedia
return $query->where($this->table . '.article_nature_id', $id);
}
public function scopeByArticleNatures($query, $ids)
{
return $query->whereIn($this->table . '.article_nature_id', $ids);
}
public function scopeByCategories($query, $categories_id)
{
return $categories_id ? $query->whereHas('categories', function ($query) use ($categories_id) {
@@ -121,6 +129,16 @@ class Article extends Model implements HasMedia
}) : $query;
}
public function scopeBotanic($query)
{
return $query->whereIn($this->table . '.product_type', [Variety::class, Specie::class]);
}
public function scopeMerchandise($query)
{
return $query->byProduct(Merchandise::class);
}
public function scopeByProduct($query, $model)
{
return $query->where($this->table . '.product_type', $model);