本文整理汇总了PHP中app\models\User::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP User::delete方法的具体用法?PHP User::delete怎么用?PHP User::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::delete方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy(User $user)
{
try {
$user->delete();
session()->flash('message_success', 'Delete successful!');
} catch (ModelNotFoundException $e) {
session()->flash('message_failed', 'Delete failed. The word you are trying to delete cannot be found.');
}
return redirect('/users/search');
}
示例2: postRegister
/**
* Handles user registration
*
* @param RegisterRequest $request
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws \Exception
*/
public function postRegister(RegisterRequest $request)
{
$user = new User(['username' => $request->input('username'), 'password' => Hash::make($request->input('password')), 'email' => $request->input('email'), 'deleted_at' => date('Y-m-d H:i:s'), 'confirm_token' => Hash::make(time() . env('APP_KEY'))]);
$user->save();
$data = ['user_email' => $request->input('email'), 'username' => $request->input('username'), 'user_subject' => trans('users.successful_registration'), 'admin_subject' => trans('users.new_user_registered'), 'user_mail_data' => ['username' => $request->input('username'), 'link' => URL::to('users/confirm') . '?token=' . $user->confirm_token], 'admin_mail_data' => ['username' => $request->input('username'), 'email' => $request->input('email'), 'created_at' => $user->created_at]];
$mail_send = $this->sendMail($data, 'emails.register', 'emails.new_user');
if ($mail_send) {
flash()->success(trans('users.register_success'));
return redirect('/');
} else {
$user->delete();
flash()->error(trans('users.registration_failed'));
return redirect()->back()->withInput($request->input());
}
}
示例3: testCascadeModel
public function testCascadeModel()
{
$user = new User(array('fullname' => 'Mukhamad Ikhsan', 'email' => 'some.email@email.com', 'password' => 'rahasia'));
$this->assertTrue($user->save());
$group = new Group(array('name' => "Testing"));
$this->assertTrue($group->save());
$user->addGroup($group);
$this->assertTrue($user->save());
$this->assertEqual(1, count($user->groups));
$this->assertEqual(1, count($group->members));
$ikhsan = User::getRepository()->findOneBy(array('email' => 'some.email@email.com'));
$testing = Group::getRepository()->findOneBy(array('name' => 'Testing'));
$this->assertEqual(1, count($ikhsan->groups));
$this->assertEqual(1, count($testing->members));
$user->delete();
$group->delete();
}
示例4: destroyUser
/**
* Destroy a user.
*
* @param App\Models\User $user
* @return void
*/
public function destroyUser(User $user)
{
$user->comments()->delete();
$user->delete();
}
示例5: destroy
/**
* @param DeleteUsrRequest $request
*
* @param User $user
* @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
* @throws \Exception
*/
public function destroy(DeleteUsrRequest $request, User $user)
{
$this->data = $user->delete();
return $this->handleRedirect($request, route('backend.users.index'));
}
示例6: delete
function delete($user_id)
{
Auth::logout();
User::delete($user_id);
return redirect('user/register');
}
示例7: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy(User $user)
{
$affectedRows = $user->delete();
return $affectedRows;
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param User $user
* @return \Illuminate\Http\RedirectResponse
* @throws \Exception
*/
public function destroy(User $user)
{
$user->delete();
return redirect()->back();
}