本文整理汇总了PHP中back函数的典型用法代码示例。如果您正苦于以下问题:PHP back函数的具体用法?PHP back怎么用?PHP back使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了back函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroyByEmail
public function destroyByEmail(SubscriberRemoveRequest $request)
{
$email = $request->only('email');
Subscriber::where(['email' => $email['email']])->delete();
Activity::log('User Unsubscribed');
return back()->withSuccess("Sorry To See You Go! :(");
}
示例2: delete_news
public function delete_news(Request $request)
{
$id = $request->item_id;
$news = News::find($id);
$news->delete();
return back()->with('message', "Новость удалена");
}
示例3: signInAuth
public function signInAuth(SignInRequest $request)
{
if ((new Authenticate($request->input('username'), $request->input('password')))->check()) {
return redirect()->route('index');
}
return back()->withErrors(['formError' => 'Invalid username or password.']);
}
示例4: authenticate
public function authenticate(Request $request)
{
// validate the info, create rules for the inputs
$rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3');
// run the validation rules on the inputs from the form
$validator = Validator::make($request->all(), $rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
return back()->withErrors($validator->errors())->withInput($request->except('password'));
// send back the input (not the password) so that we can repopulate the form
} else {
// create our user data for the authentication
$userdata = array('email' => $request->email, 'password' => $request->password);
$remember = $request->remember;
// attempt to do the login
if (Auth::attempt($userdata, $remember)) {
// validation successful!
// redirect them to the secure section or whatever
// return Redirect::to('secure');
// for now we'll just echo success (even though echoing in a controller is bad)
$user = Auth::user();
$logged_in_user = User::findOrFail($user->id);
$logged_in_user->logged_in = true;
$logged_in_user->save();
return redirect('dashboard')->with('status', 'Logged in!');
} else {
// validation not successful, send back to form
return back()->with('status', 'Couldnt log you in with the details you provided!')->withInput($request->except('password'));
}
}
}
示例5: postLogin
/**
* Handle a login request to the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postLogin(Request $request)
{
$this->validate($request, [$this->loginUsername() => 'required', 'password' => 'required']);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (Auth::attempt($this->user(), $credentials, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
if ($redirectUrl = $this->loginPath()) {
return redirect($redirectUrl)->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
} else {
return back()->withInput($request->only($this->loginUsername(), 'remember'))->withErrors([$this->loginUsername() => $this->getFailedLoginMessage()]);
}
}
示例6: responseAddGp
public function responseAddGp(Request $request)
{
$courseId = $request->input('courseId');
$name = $request->input('name');
$result = $this->gpsController->addGp($name, $courseId);
return back();
}
示例7: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof FormValidationException) {
return back()->withInput()->withErrors($e->getErrors());
}
return parent::render($request, $e);
}
示例8: upload
/**
* Handles file uploading and populating table with team data.
* @param Request $request Http request
*/
public function upload(Request $request)
{
//check file size is between 1kB and 2kB
//soccer dat is about 1.4kB
$this->validate($request, ['file' => 'between:1,2']);
//checks if the request has a file named 'file'
if ($request->hasFile('file')) {
$data = array();
//check if file uploaded successfully
if ($request->file('file')->isValid()) {
$file = $request->file('file');
//only read file
$fileObject = $file->openFile('r');
try {
$data = $this->extractData($fileObject);
$this->populateTable($data);
} catch (Exception $e) {
Log::error($e->getMessage());
return back()->withErrors(['Error Saving the data']);
}
return back()->with('success', 'Successful upload.');
} else {
return back()->withErrors(['Unable to upload file.']);
}
return 'cool';
} else {
return back()->withErrors(['No File submitted.']);
}
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// ajax upload
if ($request->ajax()) {
// check upload image
if (!$request->hasFile('uploadImg')) {
// return json data with error message noImgUpload
return response()->json(['error' => 'noUploadImg']);
} else {
if (!$this->checkImage($request->file('uploadImg'))) {
// return json data with error message wrongImgType
return response()->json(['error' => 'wrongImgType']);
} else {
if (filesize($request->file('uploadImg')->getPathname()) > 2 * 2 ** 20) {
return response()->json(['error' => 'file size is bigger than 2MB']);
}
}
}
} else {
// check has uploadImg or not
if ($request->hasFile('uploadImg')) {
// check image content
if (!$this->checkImage($request->file('uploadImg'))) {
// check fail, redirect back with errors
return back()->withInput($request->except('uploadImg'))->withErrors('小搗蛋 大頭貼只能選圖片唷:)');
}
}
}
// pass all check
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param $model
*
* @return mixed
*/
public function handle($request, Closure $next, $model)
{
// gather info
$model = '\\AbuseIO\\Models\\' . $model;
$account = Auth::user()->account;
// try to retrieve the id of the model (by getting it out the request segment or out the input)
$model_id = $request->segment(self::IDSEGMENT);
if (empty($model_id)) {
$model_id = $request->input('id');
}
// sanity checks on the model_id
if (!empty($model_id) and preg_match('/\\d+/', $model_id)) {
// only check if the checkAccountAccess exists
if (method_exists($model, 'checkAccountAccess')) {
if (!$model::checkAccountAccess($model_id, $account)) {
// if the checkAccountAccess() fails return to the last page
return back()->with('message', 'Account [' . $account->name . '] is not allowed to access this object');
}
} else {
Log::notice("CheckAccount Middleware is called for {$model}, which doesn't have a checkAccountAccess method");
}
} else {
Log::notice("CheckAccount Middleware is called, with model_id [{$model_id}] for {$model}, which doesn't match the model_id format");
}
return $next($request);
}
示例11: login
protected function login()
{
if (auth()->attempt(array('email' => Input::get('email'), 'password' => Input::get('password')), true) || auth()->attempt(array('name' => Input::get('email'), 'password' => Input::get('password')), true)) {
return Redirect::intended('/');
}
return back()->withInput()->with('message', 'Неверное имя пользователя и/или пароль!');
}
示例12: post
/**
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function post(Request $request)
{
$data['title'] = $request->bugTitle;
$data['description'] = $request->bugDescription;
$data['controller'] = $request->controller;
if (!Auth::user()) {
$data['email'] = $request->bugEmail;
$data['name'] = $request->bugName;
$validator = Validator::make($request->all(), ['bugEmail' => 'required|email|max:255', 'bugName' => 'required|max:255|alpha_space', 'bugTitle' => 'required|max:255', 'bugDescription' => 'required|max:255']);
} else {
$data['email'] = Auth::user()->email;
$data['name'] = Auth::user()->name;
$validator = Validator::make($request->all(), ['bugTitle' => 'required|max:255|email', 'bugDescription' => 'required|max:255']);
}
if ($validator->fails()) {
return back()->withErrors($validator)->withInput()->with('modal', true);
}
$response = Mail::send('emails.ladybug', $data, function ($message) use($data) {
$message->from($data['email'], $data['name']);
$message->subject("Bug Report");
$message->to('admin@uir-events.com');
});
if ($response) {
return back()->with('success', 'Your report has been sent.');
} else {
return back()->with('error', 'An error occured, please try again.');
}
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Requests\RackRequest $request)
{
//
$data = $request->except('_token');
Rack::create($data);
return back();
}
示例14: hapus
public function hapus()
{
$id = Input::get('USERS_ID');
$user = User::where('USERS_ID', '=', $id);
$user->delete();
return back();
}
示例15: update
public function update(Request $request)
{
$data = $request->all();
$user = User::whereId(Auth::user()->id)->first();
if ($user->email != $data['email']) {
$checkemail = User::where('email', '=', $data['email'])->first();
if (!$checkemail) {
$user->email = $data['email'];
} else {
alert()->warning(' ', 'Cet adresse email est déjà utilisée !')->autoclose(3500);
return back()->withInput();
}
}
$user->firstname = $data['firstname'];
$user->lastname = $data['lastname'];
if ($data['password']) {
if ($data['password'] == $data['password_confirmation']) {
$user->password = bcrypt($data['password']);
} else {
alert()->warning(' ', 'Les mots de passe ne correspondent pas !')->autoclose(3500);
return back()->withInput();
}
}
$user->save();
alert()->success(' ', 'Profil modifié !')->autoclose(3500);
return redirect('/membres/profil/');
}