fixes
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Znck\Eloquent\Relations\BelongsToThrough as RelationsBelongsToThrough;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Unity extends Model
|
||||
@@ -14,19 +17,33 @@ class Unity extends Model
|
||||
|
||||
protected $table = 'shop_unities';
|
||||
|
||||
public function package()
|
||||
public function package(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Package::class);
|
||||
}
|
||||
|
||||
public function article_family()
|
||||
public function variations(): HasMany
|
||||
{
|
||||
return $this->belongsToThrough(ArticleNature::class, Package::class, null, '', ['App\Models\Shop\ArticleNature' => 'article_family_id', 'App\Models\Shop\Package' => 'package_id']);
|
||||
return $this->hasMany(Variation::class);
|
||||
}
|
||||
|
||||
public function article_family(): RelationsBelongsToThrough
|
||||
{
|
||||
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($this->table.'.package_id', $id);
|
||||
return $query->where($this->table . '.package_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $id)
|
||||
|
||||
@@ -30,8 +30,13 @@ class Variation extends Model
|
||||
return $this->hasMany(Offer::class);
|
||||
}
|
||||
|
||||
public function scopeByPackage($query, $package_id)
|
||||
public function scopeByPackage($query, $packageId)
|
||||
{
|
||||
return $query->where($this->table.'.package_id', $package_id);
|
||||
return $query->where($this->table . '.package_id', $packageId);
|
||||
}
|
||||
|
||||
public function scopeByUnity($query, $unityId)
|
||||
{
|
||||
return $query->where($this->table . '.unity_id', $unityId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user