BaseTransformer.php 828 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Repositories\Transformers;
  3. use League\Fractal\TransformerAbstract;
  4. /**
  5. * Class ProjectTransformer.
  6. *
  7. * @package namespace App\Repositories\Transformers\Review;
  8. */
  9. abstract class BaseTransformer extends TransformerAbstract
  10. {
  11. protected $type = 'list';
  12. public function __construct($type = 'list')
  13. {
  14. $this->type = $type;
  15. }
  16. /**
  17. * Transform the Project entity.
  18. *
  19. *
  20. * @return array
  21. */
  22. public function transform($model)
  23. {
  24. switch ($this->type) {
  25. case 'list':
  26. return $this->lists($model);
  27. break;
  28. default:
  29. return $this->detail($model);
  30. break;
  31. }
  32. }
  33. public abstract function lists($model);
  34. public abstract function detail($model);
  35. }