Refactor article getter for descriptions & tags, minor fixes on tags

This commit is contained in:
Ludovic CANDELLIER
2022-06-22 22:28:18 +02:00
parent 6b1cc0f045
commit e9ab7173f8
12 changed files with 148 additions and 37 deletions

View File

@@ -24,8 +24,18 @@ class Merchandise extends Model implements HasMedia
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);
}
}

View File

@@ -3,11 +3,17 @@
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Dyrynda\Database\Support\CascadeSoftDeletes;
class TagGroup extends Model
{
use CascadeSoftDeletes, SoftDeletes;
protected $guarded = ['id'];
protected $table = 'tag_groups';
protected $cascadeDeletes = ['tags'];
public function tags()
{