fix on payment by cb

This commit is contained in:
ludo
2024-01-04 15:43:02 +01:00
parent 7c8546e450
commit 04f92c9695
14 changed files with 170 additions and 151 deletions

View File

@@ -57,17 +57,12 @@ class Article extends Model implements HasMedia
return $this->belongsTo(ArticleNature::class);
}
public function invoiceItems(): HasMany
{
return $this->hasMany(InvoiceItem::class);
}
public function offers(): HasMany
{
return $this->hasMany(Offer::class);
}
public function price_lists(): HasManyDeep
public function price_lists()
{
return $this->hasManyDeep(
PriceList::class,
@@ -77,7 +72,7 @@ class Article extends Model implements HasMedia
);
}
public function prices(): HasManyDeep
public function prices()
{
return $this->hasManyDeep(
PriceListValue::class,
@@ -166,6 +161,16 @@ class Article extends Model implements HasMedia
return $query->byProduct(Merchandise::class);
}
public function scopeVisible($query)
{
return $query->where($this->table.'.visible', 1);
}
public function scopeHomepage($query)
{
return $query->where($this->table.'.homepage', 1);
}
public function scopeByProduct($query, $model)
{
return $model ? $query->where($this->table.'.product_type', $model) : $query;
@@ -179,23 +184,14 @@ class Article extends Model implements HasMedia
public function scopeByTag($query, $tagId)
{
return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) {
$query->where('id', $tagId);
$query->byId($tagId);
}) : $query;
}
public function scopeByTags($query, $tags)
{
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
$query->whereIn('id', $tags);
}) : $query;
}
public function scopeByTagsSelected($query, $tags)
{
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
foreach ($tags as $tag) {
$query->where('id', $tag);
}
$query->byIds($tags);
}) : $query;
}
@@ -210,14 +206,4 @@ class Article extends Model implements HasMedia
$query->active()->byStockAvailable()->bySaleChannel($saleChannelId);
});
}
public function scopeVisible($query)
{
return $query->where($this->table.'.visible', 1);
}
public function scopeHomepage($query)
{
return $query->where($this->table.'.homepage', 1);
}
}