Add relations in tables, add saving states for datatables, minor fixes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -8,7 +8,29 @@ class Tag extends Model
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
public $translatable = ['name'];
|
||||
public $translatable = ['name'];
|
||||
|
||||
/*
|
||||
public function taggable()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Taggable');
|
||||
}
|
||||
*/
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Shop\Article','taggable');
|
||||
}
|
||||
|
||||
public function varieties()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Botanic\Variety','taggable');
|
||||
}
|
||||
|
||||
public function species()
|
||||
{
|
||||
return $this->morphedByMany('App\Models\Botanic\Specie','taggable');
|
||||
}
|
||||
|
||||
public function group()
|
||||
{
|
||||
|
||||
17
app/Models/Shop/Taggable.php
Normal file
17
app/Models/Shop/Taggable.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Taggable extends Model
|
||||
{
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function taggable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user