46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Traits\HashableId;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class StudyDetails extends BaseModel
|
|
{
|
|
use HashableId;
|
|
|
|
protected $table = 'study_details';
|
|
|
|
public static function historyOnly(int $studyId): self
|
|
{
|
|
return self::where('study_id', $studyId)->select(['id', 'study_id', 'clinical_history', 'surgical_history', 'lab_results', 'clinical_diagnosis'])->firstOrFail();
|
|
}
|
|
|
|
public static function seriesOnly(int $studyId): self
|
|
{
|
|
return self::where('study_id', $studyId)->select(['id', 'study_id', 'series'])->firstOrFail();
|
|
}
|
|
|
|
public function study(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Study::class);
|
|
}
|
|
|
|
public function historyIcon(): string
|
|
{
|
|
return sprintf('<i class="fa-regular fa-file-prescription %s"></i>', blank($this->clinical_history) ? 'text-muted' : 'text-success');
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'properties' => 'array',
|
|
'series' => 'array',
|
|
'assignment_log' => 'array',
|
|
];
|
|
}
|
|
}
|