Fixes on new model
This commit is contained in:
@@ -46,4 +46,9 @@ class Article extends Model implements HasMedia
|
||||
return $this->belongsTo($this->model, 'model_id');
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.id',$id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class ArticlePrice extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_prices';
|
||||
|
||||
@@ -16,7 +19,21 @@ class ArticlePrice extends Model
|
||||
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
return $this->belongsToThrough(
|
||||
'App\Models\Shop\Article',
|
||||
'App\Models\Shop\ArticleAttribute',
|
||||
null,
|
||||
'',
|
||||
['App\Models\Shop\Article' => 'article_id', 'App\Models\Shop\ArticleAttribute' => 'article_attribute_id']
|
||||
);
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->whereHas('article', function ($query) use ($id) {
|
||||
$query->byArticle($id);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,8 +12,7 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use Taggable;
|
||||
use HasMediaTrait;
|
||||
use Taggable, HasMediaTrait;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_categories';
|
||||
|
||||
Reference in New Issue
Block a user