mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange.git
synced 2026-08-19 12:24:09 +00:00
35 lines
909 B
PHP
35 lines
909 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Invoice extends Model
|
|
{
|
|
protected $fillable = ['invoice_url','amount','booking_id', 'buyer_company', 'address', 'contact_no', 'po_number', 'adjustment'];
|
|
|
|
public function booking(){
|
|
return $this->belongsTo(Booking::class);
|
|
}
|
|
|
|
public function invoiceDetails() {
|
|
return $this->hasMany(InvoiceDetails::class);
|
|
}
|
|
|
|
public function invoiceStatuses() {
|
|
return $this->hasMany(InvoiceStatuses::class);
|
|
}
|
|
|
|
public static function boot() {
|
|
parent::boot();
|
|
self::deleting(function($invoice) {
|
|
$invoice->invoiceDetails()->each(function($invoiceDetails) {
|
|
$invoiceDetails->delete();
|
|
});
|
|
$invoice->invoiceStatuses()->each(function($invoiceStatuses) {
|
|
$invoiceStatuses->delete();
|
|
});
|
|
});
|
|
}
|
|
}
|