add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 72a7b270f9
commit 0879b0abf0
459 changed files with 6219 additions and 5416 deletions

View File

@@ -4,7 +4,6 @@ namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
use Znck\Eloquent\Traits\BelongsToThrough;
@@ -13,6 +12,7 @@ class PriceListValue extends Model
use BelongsToThrough, SoftDeletes, Userstamps;
protected $guarded = ['id'];
protected $table = 'shop_price_list_values';
public function price_list()
@@ -32,15 +32,16 @@ class PriceListValue extends Model
public function scopeByPriceList($query, $id)
{
return $query->where($this->table . '.price_list_id', $id);
return $query->where($this->table.'.price_list_id', $id);
}
public function scopeByQuantity($query, $quantity)
{
return $query->orderBy('quantity', 'desc')->where($this->table . '.quantity', '<=', $quantity)->first();
return $query->orderBy('quantity', 'desc')->where($this->table.'.quantity', '<=', $quantity)->first();
}
public function scopeBySaleChannel($query, $sale_channel_id) {
public function scopeBySaleChannel($query, $sale_channel_id)
{
return $query->with([
'price_list' => function ($query) use ($sale_channel_id) {
return $query->bySaleChannel($sale_channel_id);