IMMREX7

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

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
//use App\Traits;
use Carbon\Carbon;

class BusDocument extends Model {

   // use Traits\AutoUpdateUserColumns;

    protected $primaryKey = 'idBusDoc';
    protected $table = 'bus_documents';
    protected $fillable = ['idBus', 'idDocType', 'document','expirayDate'];

    
    public function setExpirayDateAttribute($date) {
        if (strlen($date) > 0)
            $this->attributes['expirayDate'] = Carbon::createFromFormat('d-m-Y', $date);
        else
            $this->attributes['expirayDate'] = null;
    }

    public function getExpirayDateAttribute($date) {
        if ($date && $date != '0000-00-00' && $date != 'null')
            return Carbon::parse($date)->format('d-m-Y');
        return '';
    }
    
    public function docType() {
        return $this->belongsTo(DocumentType::class, 'idDocType', 'idDocType');
    }
    
    
}

Copyright © 2021 - 2025 IMMREX7