Add thumbs views in datatables with traits

This commit is contained in:
Ludovic CANDELLIER
2021-11-01 18:37:25 +01:00
parent ae20643879
commit 900da34b57
17 changed files with 127 additions and 106 deletions

View File

@@ -7,10 +7,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
use Rinvex\Tags\Traits\Taggable;
use Spatie\MediaLibrary\HasMedia;
class Specie extends Model
use App\Traits\Model\Imageable;
class Specie extends Model implements HasMedia
{
use SoftDeletes, Taggable, UserStamps;
use Imageable, SoftDeletes, Taggable, UserStamps;
protected $guarded = ['id'];
protected $table = 'botanic_species';
@@ -22,12 +25,12 @@ class Specie extends Model
public function Genre()
{
return $this->belongsTo('App\Models\Botanic\Genre');
return $this->belongsTo(Genre::class);
}
public function Varieties()
{
return $this->hasMany('App\Models\Botanic\Variety');
return $this->hasMany(Variety::class);
}
public function Articles()
@@ -37,6 +40,6 @@ class Specie extends Model
public function scopeByName($query, $name)
{
return $query->where('name', $name);
return $query->where($this->table . '.name', $name);
}
}