IMMREX7

aku nok ndi : /home/spdtg/www/schoolmis/app/
File Up :
aku nok ndi : /home/spdtg/www/schoolmis/app/HrmsHoliday.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;

class HrmsHoliday extends Model {

    protected $primaryKey = 'idHoliday';
    protected $table = 'holidays_hrms';
    protected $fillable = ['type', 'idFinancialYear','idEmployee', 'idSchool','fromDate', 'toDate', 'holidayName','designation','department'];

    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 '';
    }

}

Copyright © 2021 - 2025 IMMREX7