PaperResultTransformer.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Repositories\Transformers\Exam;
  3. use App\Repositories\Transformers\BaseTransformer;
  4. use Carbon\Carbon;
  5. use League\Fractal\TransformerAbstract;
  6. use App\Repositories\Models\Exam\PaperResult;
  7. /**
  8. * Class PaperResultTransformer.
  9. *
  10. * @package namespace App\Repositories\Transformers\Exam;
  11. */
  12. class PaperResultTransformer extends BaseTransformer
  13. {
  14. /**
  15. * Transform the PaperResult entity.
  16. *
  17. * @param \App\Repositories\Models\Exam\PaperResult $model
  18. *
  19. * @return array
  20. */
  21. public function lists($model)
  22. {
  23. return [
  24. 'id' => (int)$model->id,
  25. 'day' => $model->day,
  26. 'paper' => $model->paper,
  27. 'assign_admin' => $model->assign_admin,
  28. 'polling_admin' => $model->polling_admin,
  29. // 'result' => $model->result,
  30. 'mark' => $model->mark,
  31. 'total_mak' => $model->total_mak,
  32. 'is_answer' => $model->is_answer,
  33. 'answer_at' => $model->answer_at,
  34. 'is_exist_danger' => $model->is_exist_danger,
  35. 'imgs' => $model->imgs,
  36. 'remark' => $model->remark,
  37. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  38. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  39. ];
  40. }
  41. public function detail($model)
  42. {
  43. return [
  44. 'id' => (int)$model->id,
  45. 'day' => $model->day,
  46. 'paper' => $model->paper,
  47. 'topics' => $model->paper->topics,
  48. 'assign_admin' => $model->assign_admin,
  49. 'polling_admin' => $model->polling_admin,
  50. 'result' => $model->result,
  51. 'mark' => $model->mark,
  52. 'total_mak' => $model->total_mak,
  53. 'is_answer' => $model->is_answer,
  54. 'answer_at' => $model->answer_at,
  55. 'is_exist_danger' => $model->is_exist_danger,
  56. 'imgs' => $model->imgs,
  57. 'img_uels' => $model->img_urls,
  58. 'remark' => $model->remark,
  59. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  60. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  61. ];
  62. }
  63. }