42 lines
924 B
PHP
42 lines
924 B
PHP
<?php
|
|
|
|
namespace App\Models\Shop;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Rinvex\Tags\Traits\Taggable;
|
|
use Kirschbaum\PowerJoins\PowerJoins;
|
|
use Wildside\Userstamps\Userstamps;
|
|
|
|
use App\Traits\Model\Imageable;
|
|
|
|
class Merchandise extends Model implements HasMedia
|
|
{
|
|
use Imageable, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
|
|
|
protected $guarded = ['id'];
|
|
protected $table = 'shop_merchandises';
|
|
|
|
public function Articles()
|
|
{
|
|
return $this->morphMany(Article::class, 'product');
|
|
}
|
|
|
|
public function Producer()
|
|
{
|
|
return $this->belongsTo(Producer::class);
|
|
}
|
|
|
|
public function tags()
|
|
{
|
|
return $this->morphToMany(Tag::class, 'taggable');
|
|
}
|
|
|
|
public function scopeByProducer($query, $producer_id)
|
|
{
|
|
return $query->where('producer_id', $producer_id);
|
|
}
|
|
}
|