[WIP] Add thumb on offers, refactor categories, try to fix counter on relations polymorphic with eage loader, bad pattern !
This commit is contained in:
@@ -8,18 +8,19 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
// use Rinvex\Categories\Traits\Categorizable;
|
||||
use Rinvex\Tags\Traits\Taggable;
|
||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use InteractsWithMedia, SoftDeletes, Taggable, Userstamps;
|
||||
use HasTranslations, InteractsWithMedia, SoftDeletes, Taggable, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_categories';
|
||||
protected $table = 'categories';
|
||||
public $translatable = ['name','description'];
|
||||
|
||||
public function Articles()
|
||||
{
|
||||
@@ -31,14 +32,9 @@ class Category extends Model
|
||||
return $this->tags->articles;
|
||||
}
|
||||
|
||||
public function Shelves()
|
||||
public function countArticlesTagged()
|
||||
{
|
||||
return $this->morphedByMany(Category::class, 'categorizable');
|
||||
}
|
||||
|
||||
public function CategoryTree()
|
||||
{
|
||||
return $this->belongsTo(app('rinvex.categories.category'), 'category_id');
|
||||
return $this->tags()->withCount('Articles');
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
|
||||
Reference in New Issue
Block a user