Guest User

Untitled

a guest
Jul 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. class CompaniesController extends ApiController {
  2.  
  3. /**
  4. * @var CompanyRepository
  5. */
  6. private $repository;
  7.  
  8. /**
  9. * CompaniesController constructor.
  10. * @param CompanyRepository $repository
  11. */
  12. public function __construct(CompanyRepository $repository) {
  13. $this->repository = $repository;
  14. }
  15.  
  16.  
  17. /**
  18. * Display a listing of the resource.
  19. *
  20. * @return IlluminateHttpResponse
  21. */
  22. public function index() {
  23. return $this->response->collection(
  24. JWTAuth::parseToken()->authenticate()->companies, new CompanyTransformer
  25. );
  26. }
  27.  
  28. /**
  29. * Display the specified resource.
  30. *
  31. * @param int $id
  32. * @return IlluminateHttpResponse
  33. */
  34. public function show($id) {
  35. $item = JWTAuth::parseToken()->authenticate()->companies->find($id);
  36.  
  37. if (empty($item))
  38. throw new NotFoundHttpException();
  39.  
  40. return $this->response->item($item, new CompanyTransformer);
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment