Add relations in tables, add saving states for datatables, minor fixes
This commit is contained in:
@@ -15,6 +15,11 @@ class Specie extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'botanic_species';
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->morphToMany('App\Models\Shop\Tag', 'taggable');
|
||||
}
|
||||
|
||||
public function Genre()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Botanic\Genre');
|
||||
|
||||
@@ -31,6 +31,11 @@ class Variety extends Model implements HasMedia
|
||||
return $this->morphMany('App\Models\Shop\Article', 'product');
|
||||
}
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->morphToMany('App\Models\Shop\Tag', 'taggable');
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null) : void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32);
|
||||
|
||||
@@ -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