Add relations in tables, add saving states for datatables, minor fixes

This commit is contained in:
Ludovic CANDELLIER
2021-09-14 23:14:03 +02:00
parent 1dcc3e34a9
commit ffb9f81353
16 changed files with 255 additions and 47 deletions

View File

@@ -40,11 +40,6 @@ class Article extends Model implements HasMedia
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 invoiceItems()
{
return $this->hasMany('App\Models\Shop\InvoiceItem');
@@ -60,6 +55,11 @@ class Article extends Model implements HasMedia
return $this->morphTo();
}
public function tags()
{
return $this->morphToMany('App\Models\Shop\Tag', 'taggable');
}
public function scopeByArticle($query, $id)
{
return $query->where($this->table . '.id', $id);