Files
opensem/app/Models/Shop/Merchandise.php
Ludovic CANDELLIER 5f215cef81 coding style
2023-09-13 22:53:37 +02:00

51 lines
1.1 KiB
PHP

<?php
namespace App\Models\Shop;
use App\Traits\Model\Imageable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Kirschbaum\PowerJoins\PowerJoins;
use Rinvex\Tags\Traits\Taggable;
use Spatie\MediaLibrary\HasMedia;
use Venturecraft\Revisionable\RevisionableTrait;
use Wildside\Userstamps\Userstamps;
class Merchandise extends Model implements HasMedia
{
use Imageable, PowerJoins, RevisionableTrait, SoftDeletes, Taggable, UserStamps;
protected $guarded = ['id'];
protected $table = 'shop_merchandises';
protected $revisionEnabled = true;
protected $keepRevisionOf = [
'producer_id',
'name',
'description',
'plus',
];
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, $producerId)
{
return $query->where('producer_id', $producerId);
}
}