IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Traits;
use Carbon\Carbon;
class BusFeehead extends Model {
protected $primaryKey = 'idBusFeehead';
protected $table = 'busfeeheads';
protected $fillable = ['created_by','updated_by','idSchool', 'idFinancialYear', 'idRoute', 'idStop', 'feeheadName','description' ,'fine', 'flatFine','amount', 'fromDate', 'toDate','feeheadLabel'];
public function setFromDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['fromDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['fromDate'] = null;
}
public function getFromDateAttribute($date) {
// dd($date);
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
public function setToDateAttribute($date) {
if (strlen($date) > 0)
$this->attributes['toDate'] = Carbon::createFromFormat('d-m-Y', $date);
else
$this->attributes['toDate'] = null;
}
public function getToDateAttribute($date) {
if ($date && $date != '0000-00-00' && $date != 'null')
return Carbon::parse($date)->format('d-m-Y');
return '';
}
public function route() {
return $this->belongsTo(Route::class, 'idRoute', 'idRoute');
}
public function stop() {
return $this->belongsTo(RouteStop::class, 'idStop', 'idStop');
}
}
Copyright © 2021 -