InformationTransformer.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Repositories\Transformers\Info;
  3. use App\Repositories\Models\Info\Information;
  4. use League\Fractal\TransformerAbstract;
  5. class InformationTransformer extends TransformerAbstract
  6. {
  7. /**
  8. * Prepare data to present.
  9. *
  10. * @param Information $information
  11. * @return array
  12. */
  13. public function transform(Information $information)
  14. {
  15. // if (request()->has('id')) {
  16. // return [
  17. // 'id' => $information->id,
  18. // 'created_at' => $information->created_at ? $information->created_at->format('Y-m-d H:i:s') : null,
  19. // ];
  20. // }
  21. return [
  22. 'id' => $information->id,
  23. 'type' => $information->type,
  24. 'title' => $information->title,
  25. // 'subtitle' => $information->subtitle,
  26. 'synopsis' => $information->synopsis,
  27. 'content' => $information->content,
  28. 'status' => $information->status,
  29. 'created_at' => $information->created_at ? $information->created_at->format('Y-m-d H:i:s') : null,
  30. ];
  31. }
  32. }