本文整理汇总了PHP中GrahamCampbell\Binput\Facades\Binput::only方法的典型用法代码示例。如果您正苦于以下问题:PHP Binput::only方法的具体用法?PHP Binput::only怎么用?PHP Binput::only使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrahamCampbell\Binput\Facades\Binput
的用法示例。
在下文中一共展示了Binput::only方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postRegister
/**
* Attempt to register a new user.
*
* @return \Illuminate\Http\Response
*/
public function postRegister()
{
if (!Config::get('credentials.regallowed')) {
return Redirect::route('account.register');
}
$input = Binput::only(['first_name', 'last_name', 'email', 'password', 'password_confirmation']);
$val = UserRepository::validate($input, array_keys($input));
if ($val->fails()) {
return Redirect::route('account.register')->withInput()->withErrors($val->errors());
}
$this->throttler->hit();
try {
unset($input['password_confirmation']);
$user = Credentials::register($input);
if (!Config::get('credentials.activation')) {
$mail = ['url' => URL::to(Config::get('credentials.home', '/')), 'email' => $user->getLogin(), 'subject' => Config::get('app.name') . ' - Welcome'];
Mail::queue('credentials::emails.welcome', $mail, function ($message) use($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
$user->attemptActivation($user->getActivationCode());
$user->addGroup(Credentials::getGroupProvider()->findByName('Users'));
return Redirect::to(Config::get('credentials.home', '/'))->with('success', 'Your account has been created successfully. You may now login.');
}
$code = $user->getActivationCode();
$mail = ['url' => URL::to(Config::get('credentials.home', '/')), 'link' => URL::route('account.activate', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('app.name') . ' - Welcome'];
Mail::queue('credentials::emails.welcome', $mail, function ($message) use($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::to(Config::get('credentials.home', '/'))->with('success', 'Your account has been created. Check your email for the confirmation link.');
} catch (UserExistsException $e) {
return Redirect::route('account.register')->withInput()->withErrors($val->errors())->with('error', 'That email address is taken.');
}
}
示例2: postLogin
/**
* Attempt to login the specified user.
*
* @return \Illuminate\Http\Response
*/
public function postLogin()
{
$remember = Binput::get('rememberMe');
$input = Binput::only(['email', 'password']);
$rules = UserRepository::rules(array_keys($input));
$rules['password'] = 'required|min:6';
$val = UserRepository::validate($input, $rules, true);
if ($val->fails()) {
return Redirect::route('account.login')->withInput()->withErrors($val->errors());
}
$this->throttler->hit();
try {
$throttle = Credentials::getThrottleProvider()->findByUserLogin($input['email']);
$throttle->check();
Credentials::authenticate($input, $remember);
} catch (WrongPasswordException $e) {
return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'Your password was incorrect.');
} catch (UserNotFoundException $e) {
return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'That user does not exist.');
} catch (UserNotActivatedException $e) {
if (Config::get('credentials::activation')) {
return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'You have not yet activated this account.');
} else {
$throttle->user->attemptActivation($throttle->user->getActivationCode());
$throttle->user->addGroup(Credentials::getGroupProvider()->findByName('Users'));
return $this->postLogin();
}
} catch (UserSuspendedException $e) {
$time = $throttle->getSuspensionTime();
return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', "Your account has been suspended for {$time} minutes.");
} catch (UserBannedException $e) {
return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'You have been banned. Please contact support.');
}
return Redirect::intended(Config::get('core.home', '/'));
}
示例3: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
if (Auth::attempt(Binput::only(['email', 'password']))) {
return Redirect::intended('dashboard');
}
Throttle::hit(Request::instance(), 10, 10);
return Redirect::back()->withInput(Binput::except('password'))->with('error', 'Invalid email or password');
}
示例4: putIncident
/**
* Update an existing incident.
*
* @param \CachetHQ\Cachet\Models\Inicdent $incident
*
* @return \Illuminate\Http\JsonResponse
*/
public function putIncident(Incident $incident)
{
$incidentData = array_filter(Binput::only(['name', 'message', 'status', 'component_id', 'notify', 'visible']));
try {
$incident->update($incidentData);
} catch (Exception $e) {
throw new BadRequestHttpException();
}
return $this->item($incident);
}
示例5: putGroup
/**
* Update an existing group.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup $group
*
* @return \Illuminate\Http\JsonResponse
*/
public function putGroup(ComponentGroup $group)
{
$groupData = array_filter(Binput::only(['name', 'order']));
try {
$group->update($groupData);
} catch (Exception $e) {
throw new BadRequestHttpException();
}
return $this->item($group);
}
示例6: postUpdateUser
/**
* Updates a user.
*
* @param \Gitamin\Models\User $user
*
* @return \Illuminate\View\View
*/
public function postUpdateUser(User $user)
{
$userData = array_filter(Binput::only(['username', 'email', 'password', 'level']));
try {
$user->update($userData);
} catch (ValidationException $e) {
return Redirect::route('dashboard.group.edit', ['id' => $user->id])->withInput($userData)->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.group.edit.failure')))->withErrors($e->getMessageBag());
}
return Redirect::route('dashboard.group.edit', ['id' => $user->id])->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.group.edit.success')));
}
示例7: putGroup
/**
* Update an existing group.
*
* @param \CachetHQ\Cachet\Models\ComponentGroup $group
*
* @return \Illuminate\Http\JsonResponse
*/
public function putGroup(ComponentGroup $group)
{
$groupData = array_filter(Binput::only(['name', 'order']));
try {
$group = $this->dispatch(new UpdateComponentGroupCommand($group, Binput::get('name'), Binput::get('order', 0)));
} catch (Exception $e) {
throw new BadRequestHttpException();
}
return $this->item($group);
}
示例8: store
/**
* Store a new comment.
*
* @param int $postId
*
* @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
*
* @return \Illuminate\Http\JsonResponse
*/
public function store($postId)
{
$input = array_merge(Binput::only('body'), ['user_id' => Credentials::getuser()->id, 'post_id' => $postId, 'version' => 1]);
if (CommentRepository::validate($input, array_keys($input))->fails()) {
throw new BadRequestHttpException('Your comment was empty.');
}
$this->throttler->hit();
$comment = CommentRepository::create($input);
$contents = View::make('posts.comment', ['comment' => $comment, 'post_id' => $postId]);
return Response::json(['success' => true, 'msg' => 'Comment created successfully.', 'contents' => $contents->render(), 'comment_id' => $comment->id], 201);
}
示例9: postSubmit
/**
* Submit the contact form.
*
* @return \Illuminate\Http\Response
*/
public function postSubmit()
{
$rules = ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required', 'message' => 'required'];
$input = Binput::only(array_keys($rules));
$val = Validator::make($input, $rules);
if ($val->fails()) {
return Redirect::to($this->path)->withInput()->withErrors($val);
}
$this->throttler->hit();
Mailer::send($input['first_name'], $input['last_name'], $input['email'], $input['message']);
return Redirect::to('/')->with('success', 'Your message was sent successfully. Thank you for contacting us.');
}
示例10: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
$loginData = Binput::only(['email', 'password']);
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
return Redirect::intended('dashboard');
}
return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
}
示例11: postUser
/**
* Updates the current user.
*
* @return \Illuminate\View\View
*/
public function postUser()
{
$userData = array_filter(Binput::only(['username', 'email', 'password', 'google2fa']));
$enable2FA = (bool) array_pull($userData, 'google2fa');
// Let's enable/disable auth
if ($enable2FA && !Auth::user()->hasTwoFactor) {
$userData['google_2fa_secret'] = Google2FA::generateSecretKey();
} elseif (!$enable2FA) {
$userData['google_2fa_secret'] = '';
}
try {
Auth::user()->update($userData);
} catch (ValidationException $e) {
return Redirect::route('dashboard.user')->withInput($userData)->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))->withErrors($e->getMessageBag());
}
return Redirect::route('dashboard.user')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
}
示例12: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
$loginData = Binput::only(['email', 'password']);
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// Do we have Two Factor Auth enabled?
if (Auth::user()->hasTwoFactor) {
// Temporarily store the user.
Session::put('2fa_id', Auth::user()->id);
return Redirect::route('auth.two-factor');
}
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
return Redirect::intended('dashboard');
}
return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
}
示例13: postReset
/**
* Queue the sending of the password reset email.
*
* @return \Illuminate\Http\Response
*/
public function postReset()
{
$input = Binput::only('email');
$val = UserRepository::validate($input, array_keys($input));
if ($val->fails()) {
return Redirect::route('account.reset')->withInput()->withErrors($val->errors());
}
$this->throttler->hit();
try {
$user = Credentials::getUserProvider()->findByLogin($input['email']);
$code = $user->getResetPasswordCode();
$mail = ['link' => URL::route('account.password', ['id' => $user->id, 'code' => $code]), 'email' => $user->getLogin(), 'subject' => Config::get('core.name') . ' - Password Reset Confirmation'];
Mail::queue('emails.reset', $mail, function ($message) use($mail) {
$message->to($mail['email'])->subject($mail['subject']);
});
return Redirect::route('account.reset')->with('success', 'Check your email for password reset information.');
} catch (UserNotFoundException $e) {
return Redirect::route('account.reset')->with('error', 'That user does not exist.');
}
}
示例14: update
/**
* Update an existing event.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update($id)
{
$input = Binput::only(['title', 'location', 'date', 'body']);
$val = $val = EventRepository::validate($input, array_keys($input));
if ($val->fails()) {
return Redirect::route('events.edit', ['events' => $id])->withInput()->withErrors($val->errors());
}
$input['date'] = Carbon::createFromFormat(Config::get('date.php_format'), $input['date']);
$event = EventRepository::find($id);
$this->checkEvent($event);
$event->update($input);
return Redirect::route('events.show', ['events' => $event->id])->with('success', 'Your event has been updated successfully.');
}
示例15: update
/**
* Update an existing post.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update($id)
{
$input = Binput::only(['title', 'summary', 'body']);
$val = PostRepository::validate($input, array_keys($input));
if ($val->fails()) {
return Redirect::route('blog.posts.edit', ['posts' => $id])->withInput()->withErrors($val->errors());
}
$post = PostRepository::find($id);
$this->checkPost($post);
$post->update($input);
return Redirect::route('blog.posts.show', ['posts' => $post->id])->with('success', 'Your post has been updated successfully.');
}