accountRepo = $accountRepo; } public function login(Request $request) { if ( ! env(API_SECRET) || $request->api_secret !== env(API_SECRET)) { return 'Invalid secret'; } if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) { return $this->accountRepo->createToken($request->token_name); } else { return 'Invalid credentials'; } } public function index() { $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); $account = Auth::user()->account->load('users'); $resource = new Item($account, new AccountTransformer, 'account'); $response = $manager->createData($resource)->toArray(); $response = json_encode($response, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); return Response::make($response, 200, $headers); } }