Exemplo n.º 1
0
 /**
  * @test
  * @return void
  */
 public function it_displays_an_account()
 {
     $this->logInUser();
     $account = Account::forCurrentUser()->first();
     $response = $this->call('GET', '/api/accounts/' . $account->id);
     $content = json_decode($response->getContent(), true);
     $this->checkAccountKeysExist($content);
     //        $this->assertEquals($this->user->id, $content['user_id']);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
 }
Exemplo n.º 2
0
 /**
  * @test
  * @return void
  */
 public function it_can_update_an_existing_account()
 {
     $this->logInUser();
     $account = Account::forCurrentUser()->first();
     $response = $this->call('PUT', '/api/accounts/' . $account->id, ['name' => 'numbat']);
     $content = json_decode($response->getContent(), true);
     $this->checkAccountKeysExist($content);
     $this->assertEquals('numbat', $content['name']);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
 }
Exemplo n.º 3
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     //		$router->model('accounts', Account::class);
     Route::bind('accounts', function ($id) {
         return Account::forCurrentUser()->findOrFail($id);
     });
     Route::bind('budgets', function ($id) {
         return Budget::forCurrentUser()->findOrFail($id);
     });
     Route::bind('transactions', function ($id) {
         return Transaction::forCurrentUser()->findOrFail($id);
     });
     Route::bind('favouriteTransactions', function ($id) {
         return FavouriteTransaction::forCurrentUser()->findOrFail($id);
     });
     Route::bind('savedFilters', function ($id) {
         return SavedFilter::forCurrentUser()->findOrFail($id);
     });
 }
Exemplo n.º 4
0
 /**
  *
  * @param Request $request
  * @return Response
  */
 public function index(Request $request)
 {
     $accounts = Account::forCurrentUser()->orderBy('name', 'asc')->get();
     $accounts = $this->transform($this->createCollection($accounts, new AccountTransformer(['includeBalance' => $request->get('includeBalance')])))['data'];
     return response($accounts, Response::HTTP_OK);
 }