IMMREX7

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

<?php

namespace App;

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

class HosteliteLeave extends Model {

    protected $primaryKey = 'idHosteliteLeave';
    protected $table = 'hostelite_leaves';
    protected $fillable = ['idSchool', 'fromDate', 'toDate', 'applicationDate', 'status', 'remarks', 'idHostelite'];

    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 setApplicationDateAttribute($date) {
        if (strlen($date) > 0)
            $this->attributes['applicationDate'] = Carbon::createFromFormat('d-m-Y', $date);
        else
            $this->attributes['applicationDate'] = null;
    }

    public function getApplicationDateAttribute($date) {
        if ($date && $date != '0000-00-00' && $date != 'null')
            return Carbon::parse($date)->format('d-m-Y');
        return '';
    }

}

Copyright © 2021 - 2025 IMMREX7