ResourceTransformer.php 863 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of the Jiannei/lumen-api-starter.
  4. *
  5. * (c) Jiannei <longjian.huang@foxmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace App\Repositories\Transformers;
  11. use App\Models\Resource;
  12. use League\Fractal\TransformerAbstract;
  13. class ResourceTransformer extends TransformerAbstract
  14. {
  15. public function transform(Resource $resource)
  16. {
  17. $data = [
  18. 'id' => $resource->id,
  19. 'title' => $resource->title,
  20. 'cover' => $resource->cover,
  21. 'video' => $resource->video,
  22. 'view_num' => $resource->view_num,
  23. 'status' => $resource->status,
  24. 'created_at' => $resource->created_at,
  25. 'updated_at' => $resource->updated_at,
  26. ];
  27. return $data;
  28. }
  29. }