49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
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';
|
|
|
|
public function invoice()
|
|
{
|
|
return $this->belongsTo(Invoice::class);
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
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);
|
|
}
|
|
}
|