add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 297dcc62d2
commit 39c80ce6d1
459 changed files with 6219 additions and 5416 deletions

View File

@@ -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);
},
]);