IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class FoodTransactionDetail extends Model {
protected $primaryKey = 'idTransactionDetail';
protected $table = 'food_transaction_details';
protected $fillable = ['idTransaction', 'idStudent', 'idProduct','qty', 'unitPrice', 'amountPaid', 'discount','status','paymentDate'];
public function setPaymentDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['paymentDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['paymentDate'] = null;
}
public function getPaymentDateAttribute($date) {
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
public function feehead() {
return $this->belongsTo(Food::class, 'id', 'idProduct');
}
}
Copyright © 2021 -