39 lines
833 B
PHP
39 lines
833 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class SubmissionAnswer extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'submission_id',
|
|
'checklist_item_id',
|
|
'value',
|
|
'unit',
|
|
'page_reference',
|
|
'consultant_note',
|
|
'officer_note',
|
|
'validation_status',
|
|
];
|
|
|
|
public function submission(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Submission::class);
|
|
}
|
|
|
|
public function item(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ChecklistItem::class, 'checklist_item_id');
|
|
}
|
|
|
|
public function numericValue(): ?float
|
|
{
|
|
return is_numeric($this->value) ? (float) $this->value : null;
|
|
}
|
|
}
|