fix on payment by cb
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ class Invoice extends Model
|
||||
return $query->where('uuid', $uuid);
|
||||
}
|
||||
|
||||
public function scopeById($query, $id)
|
||||
{
|
||||
return $query->where('id', $id);
|
||||
}
|
||||
|
||||
public function scopeByPeriod($query, $start, $end)
|
||||
{
|
||||
return $query->whereBetween('created_at', [$start, $end]);
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class InvoicePayment extends Model
|
||||
{
|
||||
use RevisionableTrait, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_invoice_payments';
|
||||
@@ -15,8 +19,30 @@ class InvoicePayment extends Model
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function scopeByInvoice($query, $invoice_id)
|
||||
public function order()
|
||||
{
|
||||
return $query->where('invoice_id', $invoice_id);
|
||||
return $this->belongsToThrough(Order::class, Invoice::class);
|
||||
}
|
||||
|
||||
public function scopeByInvoice($query, $invoiceId)
|
||||
{
|
||||
return $query->where('invoice_id', $invoiceId);
|
||||
}
|
||||
|
||||
public function scopeValidated($query)
|
||||
{
|
||||
return $query->where('validated', 1);
|
||||
}
|
||||
|
||||
public function scopeByOrder($query, $orderId)
|
||||
{
|
||||
return $query->whereHas('order', function($query) use ($orderId) {
|
||||
return $query->byOrder($orderId);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByPaymentType($query, $paymentType)
|
||||
{
|
||||
return $query->where('payment_type', $paymentType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,4 +92,11 @@ class Order extends Model
|
||||
{
|
||||
return $query->whereBetween($field, [$start, $end]);
|
||||
}
|
||||
|
||||
public function scopeByInvoice($query, $invoiceId)
|
||||
{
|
||||
return $query->whereHas('invoice', function ($query) use ($invoiceId) {
|
||||
$query->byId($invoiceId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,6 @@ class Tag extends parentTag
|
||||
|
||||
public $translatable = [];
|
||||
|
||||
/*
|
||||
public function taggable()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Taggable');
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO
|
||||
public function offers()
|
||||
{
|
||||
@@ -80,4 +73,14 @@ class Tag extends parentTag
|
||||
$query->byCategoryParent($category_id);
|
||||
}]);
|
||||
}
|
||||
|
||||
public function scopeById($query, $id)
|
||||
{
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByIds($query, $ids)
|
||||
{
|
||||
return $query->whereIn($this->table.'.id', $ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user