DrugTransformer.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Repositories\Transformers\TCM;
  3. use App\Repositories\Models\TCM\Prescription;
  4. use League\Fractal\TransformerAbstract;
  5. use App\Repositories\Models\TCM\Drug;
  6. /**
  7. * Class DrugTransformer.
  8. *
  9. * @package namespace App\Repositories\Transformers\TCM;
  10. */
  11. class DrugTransformer extends TransformerAbstract
  12. {
  13. /**
  14. * Transform the Drug entity.
  15. *
  16. * @param \App\Repositories\Models\TCM\Drug $model
  17. *
  18. * @return array
  19. */
  20. public function transform(Drug $model)
  21. {
  22. return [
  23. 'id' => (int)$model->id,
  24. "name" => $model->name,
  25. "type" => $model->type,
  26. "type_text" => Prescription::$drugTypeMap[$model->type],
  27. "unit" => $model->unit,
  28. "area" => $model->area,
  29. "remark" => $model->remark,
  30. "letter" => $model->letter,
  31. "initial" => $model->initial,
  32. // "import_id" => $model->import_id,
  33. "sort" => $model->sort,
  34. // "commentable_id" => $model->commentable_id,
  35. // "commentable_type" => $model->commentable_type,
  36. "status" => $model->status,
  37. 'created_at' => $model->created_at,
  38. 'updated_at' => $model->updated_at
  39. ];
  40. }
  41. }