refactor, better class namespace intergration
This commit is contained in:
@@ -16,34 +16,25 @@ class Unity extends Model
|
||||
|
||||
public function package()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Package');
|
||||
return $this->belongsTo(Package::class);
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsToThrough('App\Models\Shop\ArticleNature', 'App\Models\Shop\Package', null, '', ['App\Models\Shop\ArticleNature' => 'article_family_id', 'App\Models\Shop\Package' => 'package_id']);
|
||||
return $this->belongsToThrough(ArticleNature::class, Package::class, null, '', ['App\Models\Shop\ArticleNature' => 'article_family_id', 'App\Models\Shop\Package' => 'package_id']);
|
||||
}
|
||||
|
||||
public function scopeByPackage($query, $id)
|
||||
{
|
||||
return $query->where('package_id', $id);
|
||||
return $query->where($this->table . '.package_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'package', function ($query) use ($id) {
|
||||
return $query->whereHas('package', function ($query) use ($id) {
|
||||
$query->byArticleNature($id);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function scopeActive($query, $active = 1)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'third_party', function ($query) use ($active) {
|
||||
$query->active($active);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user