This commit is contained in:
Ludovic CANDELLIER
2021-04-05 22:31:15 +02:00
parent e6e86767d3
commit 0620ab19c4
12 changed files with 167 additions and 137 deletions

View File

@@ -10,20 +10,18 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
class Variety extends Model implements HasMedia
{
use HasMediaTrait;
use EloquentJoin;
use Taggable;
use EloquentJoin, HasMediaTrait, Taggable;
protected $guarded = ['id'];
protected $guarded = ['id'];
protected $table = 'botanic_varieties';
public function Specie()
{
return $this->belongsTo('App\Models\Botanic\Specie');
}
{
return $this->belongsTo('App\Models\Botanic\Specie');
}
public function Articles()
{
return $this->morphMany('App\Models\Shop\Article','product');
}
public function Articles()
{
return $this->morphMany('App\Models\Shop\Article','product');
}
}

View File

@@ -11,65 +11,60 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
class Article extends Model implements HasMedia
{
use Categorizable, Taggable, HasMediaTrait, EloquentJoin;
use Categorizable, EloquentJoin, HasMediaTrait, Taggable;
protected $guarded = ['id'];
protected $table = 'shop_articles';
protected $guarded = ['id'];
protected $table = 'shop_articles';
public function article_family()
{
return $this->belongsTo('App\Models\Shop\ArticleFamily');
}
public function article_family()
{
return $this->belongsTo('App\Models\Shop\ArticleFamily');
}
public function attributes()
{
return $this->hasMany('App\Models\Shop\ArticleAttribute');
}
public function images()
{
return $this->hasMany('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
}
public function images()
{
return $this->hasMany('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
}
public function image()
{
return $this->hasOne('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
}
public function image()
{
return $this->hasOne('App\Models\Core\Media','model_id')->where('model_type','App\Models\Shop\Article');
}
public function inventories()
{
return $this->hasMany('App\Models\Shop\Inventory');
}
public function inventories()
{
return $this->hasMany('App\Models\Shop\Inventory');
}
public function invoiceItems()
{
return $this->hasMany('App\Models\Shop\InvoiceItem');
}
public function invoiceItems()
{
return $this->hasMany('App\Models\Shop\InvoiceItem');
}
public function prices()
{
return $this->hasMany('App\Models\Shop\Price');
}
public function prices()
{
return $this->hasMany('App\Models\Shop\Price');
}
public function product()
{
return $this->morphTo();
}
public function product()
{
return $this->morphTo();
}
public function scopeByArticle($query, $id)
{
return $query->where('shop_articles.id',$id);
}
public function scopeByArticle($query, $id)
{
return $query->where('shop_articles.id',$id);
}
public function scopeByCategory($query, $category_id)
{
public function scopeByCategory($query, $category_id)
{
}
}
public function scopeByFamily($query, $id)
{
return $query->where('shop_articles.article_family_id',$id);
}
public function scopeByFamily($query, $id)
{
return $query->where('shop_articles.article_family_id',$id);
}
}