IMMREX7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Carbon\Carbon;
class ShortStory extends Model
{
protected $primaryKey = 'idStory';
protected $table = 'short_stories';
protected $fillable = ['idSchool', 'idFinancialYear','idClass','title','source','story','image','isPublished','publishDate'];
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 -