SettingTransformer.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Repositories\Transformers\Base;
  3. use Carbon\Carbon;
  4. use League\Fractal\TransformerAbstract;
  5. use App\Repositories\Models\Base\Setting;
  6. /**
  7. * Class SettingTransformer.
  8. *
  9. * @package namespace App\Repositories\Transformers\Base;
  10. */
  11. class SettingTransformer extends TransformerAbstract
  12. {
  13. /**
  14. * Transform the Setting entity.
  15. *
  16. * @param \App\Repositories\Models\Base\Setting $model
  17. *
  18. * @return array
  19. */
  20. public function transform(Setting $model)
  21. {
  22. return [
  23. 'id' => (int)$model->id,
  24. 'name' => $model->name,
  25. 'type' => $model->type,
  26. 'parent_id' => $model->parent_id,
  27. 'parent_name' => $model->parent ? $model->parent->name : '',
  28. 'sort' => $model->sort,
  29. 'value' => $model->value,
  30. 'is_init' => $model->is_init,
  31. 'status' => $model->status,
  32. 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
  33. 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
  34. ];
  35. }
  36. }