IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class EmployeeExpense extends Model {
protected $primaryKey = 'idExpense';
protected $table = 'employee_expences';
protected $fillable = ['idFinancialYear','idEmployee', 'amount', 'remarks', 'idSchool', 'date', 'billCopy'];
public function employee() {
return $this->belongsTo(Employee::class, 'idEmployee', 'idEmployee');
}
public function setDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['date'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['date'] = null;
}
public function getDateAttribute($date) {
if (strlen($date) > 4){
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}else return $date;
}
}
Copyright © 2021 -