IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
use App\Traits;
class FinancialYear extends Model {
use Traits\AutoUpdateUserColumns;
// protected $dateFormat = 'Y-m-d';
protected $primaryKey = 'idFinancialYear';
protected $table = 'financial_years';
protected $fillable = ['financialYearName','idSchool', 'startDate', 'endDate'];
public function setStartDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['startDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['startDate'] = null;
}
public function getStartDateAttribute($date) {
// dd($date);
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
public function setEndDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['endDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['endDate'] = null;
}
public function getEndDateAttribute($date) {
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
}
Copyright © 2021 -