PointTransformer.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Repositories\Transformers\Area;
  3. use App\Repositories\Transformers\BaseTransformer;
  4. use Carbon\Carbon;
  5. use League\Fractal\TransformerAbstract;
  6. use App\Repositories\Models\Area\Point;
  7. /**
  8. * Class PointTransformer.
  9. *
  10. * @package namespace App\Repositories\Transformers\Area;
  11. */
  12. class PointTransformer extends BaseTransformer
  13. {
  14. /**
  15. * Transform the Point entity.
  16. *
  17. * @param \App\Repositories\Models\Area\Point $model
  18. *
  19. * @return array
  20. */
  21. public function lists($model)
  22. {
  23. return [
  24. 'id' => (int)$model->id,
  25. 'name' => $model->name,
  26. 'cover' => $model->cover,
  27. 'type' => $model->type,
  28. 'project' => $model->project,
  29. 'parent_id' => $model->parent_id,
  30. 'area' => $model->area,
  31. 'status' => $model->status,
  32. /* place your other model properties here */
  33. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  34. ];
  35. }
  36. public function detail($model)
  37. {
  38. return [
  39. 'id' => (int)$model->id,
  40. 'name' => $model->name,
  41. 'cover' => $model->cover,
  42. 'type' => $model->type,
  43. 'project_id' => $model->project_id,
  44. 'area_id' => $model->area_id,
  45. 'parent_id' => $model->parent_id,
  46. 'status' => $model->status,
  47. 'body' => $model->body,
  48. /* place your other model properties here */
  49. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  50. ];
  51. }
  52. }