43 lines
936 B
PHP
43 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
use Wildside\Userstamps\Userstamps;
|
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
|
|
class ArticleNature extends Model
|
|
{
|
|
use HasRelationships, SoftDeletes, UserStamps;
|
|
|
|
protected $guarded = ['id'];
|
|
protected $table = 'shop_article_natures';
|
|
|
|
public function articles()
|
|
{
|
|
return $this->hasMany(Article::class);
|
|
}
|
|
|
|
public function scopeByArticleNature($query, $id)
|
|
{
|
|
return $query->where($this->table . '.id', $id);
|
|
}
|
|
|
|
public function scopeByBotanic($query)
|
|
{
|
|
return $query->ByProductType(1);
|
|
}
|
|
|
|
public function scopeByMerchandise($query)
|
|
{
|
|
return $query->ByProductType(2);
|
|
}
|
|
|
|
public function scopeByProductType($query, $type)
|
|
{
|
|
return $query->where($this->table . '.product_type', $type);
|
|
}
|
|
}
|