%PDF- %PDF-
Direktori : /var/www/html/klinisol/klinisol-api/app/Models/ |
Current File : /var/www/html/klinisol/klinisol-api/app/Models/Icd.php |
<?php namespace App\Models; use Carbon\Carbon; /** * @property integer id * @property string version * @property mixed valid_from * @property mixed valid_to * @property string status */ class Icd extends BaseModel { const DRAFT = 'draft'; const PUBLISHED = 'published'; const EXPIRED = 'expired'; protected $table = 'icds'; protected $fillable = [ 'version', 'valid_from', 'valid_to', 'status', ]; protected $casts = [ 'id' => 'int', 'version' => 'string', 'valid_from' => 'datetime', 'valid_to' => 'datetime', 'status' => 'string', ]; public function questions() { return $this->hasMany(IcdQuestion::class); } public function publish() { $this->valid_from = Carbon::now(); $this->valid_to = null; $this->status = self::PUBLISHED; $this->save(); return $this; } public function expire() { $this->valid_to = Carbon::now(); $this->status = self::EXPIRED; $this->save(); return $this; } }