本文整理汇总了PHP中app\models\Account::forCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::forCurrentUser方法的具体用法?PHP Account::forCurrentUser怎么用?PHP Account::forCurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Account
的用法示例。
在下文中一共展示了Account::forCurrentUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: it_displays_an_account
/**
* @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());
}
示例2: it_can_update_an_existing_account
/**
* @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());
}
示例3: boot
/**
* 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);
});
}
示例4: index
/**
*
* @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);
}