IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class Noticeboard extends Model {
protected $primaryKey = 'idNoticeboard';
protected $table = 'noticeboard';
protected $fillable = ['idClass', 'idFinancialYear', 'idSchool', 'idSection', 'cardholder', 'subject', 'notice', 'noticeFile', 'isPublished', 'publishDate'];
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 -