fix on payment by cb

This commit is contained in:
ludo
2024-01-04 15:43:02 +01:00
parent 8a463e7b9e
commit 03027cde01
14 changed files with 170 additions and 151 deletions

View File

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