IMMREX7

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

<?php

namespace App;

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

class Homework extends Model {

    protected $primaryKey = 'idHomework';
    protected $table = 'homework';
    protected $fillable = ['idClass', 'idFinancialYear', 'idSchool', 'idSection', 'idStudent', 'subject', 'homework', 'homeworkFile', 'isPublished', 'publishDate','total_student','submit_student'];

    public function classM() {
        return $this->belongsTo(ClassM::class, 'idClass', 'idClass');
    }

    public function section() {
        return $this->belongsTo(Section::class, 'idSection', 'idSection');
    }

    public function student() {
        return $this->belongsTo(AdmEntry::class, 'idStudent', 'idStudent');
    }

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

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

}

Copyright © 2021 - 2025 IMMREX7