IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class Quotation extends Model {
protected $primaryKey = 'idQuotation';
protected $table = 'quotations';
protected $fillable = ['idSchool', 'idFinancialYear', 'quotationDate', 'expDeliveryDate', 'shipmentPreference', 'idSupplier'];
public function setQuotationDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['quotationDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['quotationDate'] = null;
}
public function getQuotationDateAttribute($date) {
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
public function setExpDeliveryDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['expDeliveryDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['expDeliveryDate'] = null;
}
public function getExpDeliveryDateAttribute($date) {
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
public function supplier() {
return $this->belongsTo(Supplier::class, 'idSupplier', 'idSupplier');
}
public function details() {
return $this->hasMany(QuotationDetail::class, 'idQuotation', 'idQuotation');
}
}
Copyright © 2021 -