add shipping rules
This commit is contained in:
@@ -2,19 +2,19 @@
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
use App\Traits\Model\HasComments;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
use BelongsToThrough, HasComments, HasRelationships;
|
||||
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_offers';
|
||||
|
||||
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo(Article::class);
|
||||
@@ -80,37 +80,37 @@ class Offer extends Model
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.article_id', $id);
|
||||
return $query->where($this->table.'.article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByArticles($query, $ids)
|
||||
{
|
||||
return $query->whereIn($this->table . '.article_id', $ids);
|
||||
return $query->whereIn($this->table.'.article_id', $ids);
|
||||
}
|
||||
|
||||
public function scopeByID($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.id', $id);
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByOffer($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.id', $id);
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStatus($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.status_id', $id);
|
||||
return $query->where($this->table.'.status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByVariation($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.variation_id', $id);
|
||||
return $query->where($this->table.'.variation_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByStockAvailable($query)
|
||||
{
|
||||
return $query->where($this->table . '.stock_current', '>', 0);
|
||||
return $query->where($this->table.'.stock_current', '>', 0);
|
||||
}
|
||||
|
||||
public function scopeByArticleNature($query, $article_nature_id)
|
||||
@@ -165,16 +165,16 @@ class Offer extends Model
|
||||
public function scopeWithPriceListsBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->with([
|
||||
'price_lists' => function($query) use ($sale_channel_id) {
|
||||
'price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
}
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
public function scopeWithPriceListValuesBySaleChannel($query, $sale_channel_id)
|
||||
{
|
||||
return $query->with([
|
||||
'price_list_values' => function($query) use ($sale_channel_id) {
|
||||
'price_list_values' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
]);
|
||||
@@ -183,10 +183,10 @@ class Offer extends Model
|
||||
public function scopeWithPriceBySaleChannelByQuantity($query, $sale_channel_id, $quantity = 1)
|
||||
{
|
||||
return $query->with([
|
||||
'price_lists' => function($query) use ($sale_channel_id) {
|
||||
'price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
'price_lists.price_list_values' => function($query) use ($quantity) {
|
||||
'price_lists.price_list_values' => function ($query) use ($quantity) {
|
||||
$query->byQuantity($quantity);
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user