ExamPaperModel.php 903 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class ExamPaperModel extends BaseModel
  5. {
  6. protected $table = 'exam_papers';
  7. public $timestamps = false;
  8. protected $guarded = [];
  9. protected $fillable = [
  10. 'type',
  11. 'name',
  12. 'scene_type',
  13. 'subject_id',
  14. 'score_total',
  15. 'topic_count',
  16. 'is_charge',
  17. 'status',
  18. 'sort',
  19. 'remark',
  20. 'mark',
  21. 'create_time'
  22. ];
  23. /**
  24. * 最新答题数据
  25. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  26. */
  27. public function answer()
  28. {
  29. return $this->hasOne(ExamAnswerModel::class, 'paper_id', 'id')
  30. ->where(['status' => 1, 'mark' => 1])
  31. ->select(['id', 'score', 'accurate_count','user_id', 'answer_times', 'answer_count', 'is_submit'])
  32. ->orderBy('create_time','desc');
  33. }
  34. }