MedicalQuestion.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\model;
  4. use think\Model;
  5. /**
  6. * 医学计算器问题模型
  7. * Class MedicalQuestion
  8. * @package app\model
  9. */
  10. class MedicalQuestion extends Model
  11. {
  12. /**
  13. * 数据表名称
  14. * @var string
  15. */
  16. protected $name = 'medical_questions';
  17. /**
  18. * 自动写入时间戳
  19. * @var bool
  20. */
  21. protected $autoWriteTimestamp = false;
  22. /**
  23. * 设置字段信息
  24. * @var array
  25. */
  26. protected $schema = [
  27. 'id' => 'int',
  28. 'medical_calculator_id' => 'int',
  29. 'question' => 'string',
  30. 'variable_name' => 'string',
  31. 'type' => 'string',
  32. 'score' => 'float',
  33. ];
  34. /**
  35. * 允许批量赋值的字段
  36. * @var array
  37. */
  38. protected $allowField = [
  39. 'medical_calculator_id',
  40. 'question',
  41. 'variable_name',
  42. 'type',
  43. 'score'
  44. ];
  45. /**
  46. * 获取选项列表
  47. */
  48. public function options()
  49. {
  50. return $this->hasMany(MedicalOption::class, 'medical_question_id', 'id')
  51. ->order('id', 'asc');
  52. }
  53. /**
  54. * 获取所属计算器
  55. */
  56. public function calculator()
  57. {
  58. return $this->belongsTo(MedicalCalculator::class, 'medical_calculator_id', 'id');
  59. }
  60. }