本文整理汇总了PHP中app\models\Account::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Account::user方法的具体用法?PHP Account::user怎么用?PHP Account::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Account
的用法示例。
在下文中一共展示了Account::user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* POST /api/accounts/{accounts}
* @param InsertAccountRequest $request
* @return Response
*/
public function store(InsertAccountRequest $request)
{
$account = new Account($request->only(['name']));
$account->user()->associate(Auth::user());
$account->save();
$account = $this->transform($this->createItem($account, new AccountTransformer()))['data'];
$pusher = new Pusher(env('PUSHER_PUBLIC_KEY'), env('PUSHER_SECRET_KEY'), env('PUSHER_APP_ID'));
$data = 'account created!';
$pusher->trigger('myChannel', 'accountCreated', $data);
return response($account, Response::HTTP_CREATED);
}
示例2: run
public function run()
{
$users = User::all();
foreach ($users as $user) {
foreach ($this->accounts as $account) {
$tmp = new Account(['name' => $account]);
$tmp->user()->associate($user);
$tmp->save();
}
}
}
示例3: it_can_delete_an_account
/**
* @test
* @return void
*/
public function it_can_delete_an_account()
{
$this->logInUser();
$name = 'echidna';
$account = new Account(compact('name'));
$account->user()->associate($this->user);
$account->save();
$response = $this->call('DELETE', '/api/accounts/' . $account->id);
$this->assertEquals(204, $response->getStatusCode());
$response = $this->call('DELETE', '/api/account/' . $account->id);
$this->assertEquals(404, $response->getStatusCode());
}