Add plus on products

This commit is contained in:
Ludovic CANDELLIER
2022-04-25 20:02:28 +02:00
parent ee0954931f
commit 3c8fab27da
15 changed files with 263 additions and 47 deletions

View File

@@ -10,6 +10,8 @@ use Rinvex\Tags\Traits\Taggable;
use Spatie\MediaLibrary\HasMedia;
use App\Traits\Model\Imageable;
use App\Models\Shop\Tag;
use App\Models\Shop\Article;
class Specie extends Model implements HasMedia
{
@@ -20,7 +22,7 @@ class Specie extends Model implements HasMedia
public function tags()
{
return $this->morphToMany('App\Models\Shop\Tag', 'taggable');
return $this->morphToMany(Tag::class, 'taggable');
}
public function Genre()
@@ -35,7 +37,7 @@ class Specie extends Model implements HasMedia
public function Articles()
{
return $this->morphMany('App\Models\Shop\Article', 'product');
return $this->morphMany(Article::class, 'product');
}
public function scopeByName($query, $name)

View File

@@ -12,6 +12,9 @@ use Wildside\Userstamps\Userstamps;
use App\Traits\Model\Imageable;
use App\Models\Shop\Article;
use App\Models\Shop\Tag;
class Variety extends Model implements HasMedia
{
use Imageable, PowerJoins, SoftDeletes, Taggable, UserStamps;
@@ -21,16 +24,16 @@ class Variety extends Model implements HasMedia
public function Specie()
{
return $this->belongsTo('App\Models\Botanic\Specie');
return $this->belongsTo(Specie::class);
}
public function Articles()
{
return $this->morphMany('App\Models\Shop\Article', 'product');
return $this->morphMany(Article::class, 'product');
}
public function tags()
{
return $this->morphToMany('App\Models\Shop\Tag', 'taggable');
return $this->morphToMany(Tag::class, 'taggable');
}
}

View File

@@ -19,9 +19,14 @@ class Producer extends Model implements HasMedia
protected $guarded = ['id'];
protected $table = 'shop_producers';
public function Articles()
{
}
public function Merchandises()
{
return $this->morphMany(Article::class, 'product');
return $this->hasMany(Merchandise::class);
}
public function tags()