PaperTransformer.php 824 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Repositories\Transformers\Exam;
  3. use Carbon\Carbon;
  4. use League\Fractal\TransformerAbstract;
  5. use App\Repositories\Models\Exam\Paper;
  6. /**
  7. * Class PaperTransformer.
  8. *
  9. * @package namespace App\Repositories\Transformers\Exam;
  10. */
  11. class PaperTransformer extends TransformerAbstract
  12. {
  13. /**
  14. * Transform the Paper entity.
  15. *
  16. * @param \App\Repositories\Models\Exam\Paper $model
  17. *
  18. * @return array
  19. */
  20. public function transform(Paper $model)
  21. {
  22. return [
  23. 'id' => (int)$model->id,
  24. 'name' => $model->name,
  25. 'topics' => $model->topics,
  26. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  27. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  28. ];
  29. }
  30. }