Add thumbs views in datatables with traits
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,16 @@ namespace App\Models\Botanic;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use Spatie\Image\Manipulations;
|
||||
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Kirschbaum\PowerJoins\PowerJoins;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
use App\Traits\Model\Imageable;
|
||||
|
||||
class Variety extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
||||
use Imageable, PowerJoins, SoftDeletes, Taggable, UserStamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'botanic_varieties';
|
||||
@@ -36,13 +33,4 @@ class Variety extends Model implements HasMedia
|
||||
{
|
||||
return $this->morphToMany('App\Models\Shop\Tag', 'taggable');
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null) : void
|
||||
{
|
||||
$this->addMediaConversion('thumb')->fit(Manipulations::FIT_CROP, 32, 32);
|
||||
$this->addMediaConversion('mini')->fit(Manipulations::FIT_CROP, 96, 96);
|
||||
$this->addMediaConversion('preview')->fit(Manipulations::FIT_CROP, 160, 160);
|
||||
$this->addMediaConversion('normal')->fit(Manipulations::FIT_CROP, 480, 480);
|
||||
// $this->addMediaConversion('zoom')->fit(Manipulations::FIT_CROP, 1200, 1200)->withResponsiveImages();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user