fix on payment by cb
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user