123456789101112131415161718192021222324252627282930 |
- <?php
- namespace App\Model;
- use Illuminate\Database\Eloquent\Model;
- class MedicalCalculatorQuestion extends Model
- {
- protected $fillable = [
- 'medical_calculator_id', 'question', 'type', 'options', 'score', 'variable'
- ];
- protected $casts = [
- 'options' => 'array',
- ];
- public function calculator()
- {
- return $this->belongsTo(MedicalCalculator::class, 'medical_calculator_id');
- }
- public function getTypeTextAttribute()
- {
- $types = [
- 'text' => '填空',
- 'radio' => '单选',
- 'checkbox' => '多选'
- ];
- return $types[$this->type] ?? '未知';
- }
- }
|