belongsTo(ArticleNature::class); } public function images() { return $this->hasMany('App\Models\Core\Media', 'model_id')->where('model_type', 'App\Models\Shop\Article'); } public function image() { return $this->hasOne('App\Models\Core\Media', 'model_id')->where('model_type', 'App\Models\Shop\Article'); } public function invoiceItems() { return $this->hasMany(InvoiceItem::class); } public function prices() { return $this->hasMany(Price::class); } public function product() { return $this->morphTo(); } public function tags() { return $this->morphToMany(Tag::class, 'taggable'); } public function scopeByArticle($query, $id) { return $query->where($this->table . '.id', $id); } public function scopeByCategory($query, $category_id) { } public function scopeByArticleNature($query, $id) { return $query->where($this->table . '.article_nature_id', $id); } public function scopeByProduct($query, $model) { return $query->where($this->table . '.product_type', $model); } public function scopeByProductId($query, $model_id) { return $query->where($this->table . '.product_id', $model_id); } 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(); } }