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! :("); }
public function delete_news(Request $request) { $id = $request->item_id; $news = News::find($id); $news->delete(); return back()->with('message', "Новость удалена"); }
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.']); }
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')); } } }
/** * 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()]); } }
public function responseAddGp(Request $request) { $courseId = $request->input('courseId'); $name = $request->input('name'); $result = $this->gpsController->addGp($name, $courseId); return back(); }
/** * 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); }
/** * 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.']); } }
/** * 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); }
/** * 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); }
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', 'Неверное имя пользователя и/или пароль!'); }
/** * @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('*****@*****.**'); }); if ($response) { return back()->with('success', 'Your report has been sent.'); } else { return back()->with('error', 'An error occured, please try again.'); } }
/** * 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(); }
public function hapus() { $id = Input::get('USERS_ID'); $user = User::where('USERS_ID', '=', $id); $user->delete(); return back(); }
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/'); }
/** * Account sign in form processing. * * @return Redirect */ public function postSignin() { // Declare the rules for the form validation $rules = array('email' => 'required|email', 'password' => 'required|between:3,32'); // Create a new validator instance from our validation rules $validator = Validator::make(Input::all(), $rules); // If validation fails, we'll exit the operation now. if ($validator->fails()) { // Ooops.. something went wrong return back()->withInput()->withErrors($validator); } try { // Try to log the user in if (Sentinel::authenticate(Input::only('email', 'password'), Input::get('remember-me', false))) { // Redirect to the dashboard page return Redirect::route("dashboard")->with('success', Lang::get('auth/message.signin.success')); } $this->messageBag->add('email', Lang::get('auth/message.account_not_found')); } catch (NotActivatedException $e) { $this->messageBag->add('email', Lang::get('auth/message.account_not_activated')); } catch (ThrottlingException $e) { $delay = $e->getDelay(); $this->messageBag->add('email', Lang::get('auth/message.account_suspended', compact('delay'))); } // Ooops.. something went wrong return back()->withInput()->withErrors($this->messageBag); }
public function store(Request $request, Task $task) { $task->addNote(new Note($request->all())); $task->setUpdatedAt(Carbon::now()->toDateTimeString()); $task->save(); return back(); }
public function getDetachField($field_id, $ct_id) { $type = ContentType::find($ct_id); $field = Field::find($field_id); $type->fieldable()->detach($field->id); return back()->withMsg("Поле \"{$field->name}\" от материала \"{$type->name}\" успешно отвязано"); }
/** * Store a newly created resource in storage. * * @return Response */ public function store($jenis) { if ($jenis == 'kategori') { $rules = array("judul" => "required", "status" => "required"); $data = new Kategori(); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { $data->judul = strtolower(Input::get('judul')); $data->aktif = Input::get('status'); $data->save(); return redirect('/bos/kategori'); } else { return back()->withInput()->with('message', 'Lengkapi data terlebih dahulu'); } } if ($jenis == 'artikel') { $rules = array("judul" => "required"); $valid = Validator::make(Input::all(), $rules); if ($valid->passes()) { $data = new Artikel(); $data->judul = ucwords(Input::get('judul')); $data->slug = strtolower(str_replace(" ", "-", trim(Input::get('judul')))); $data->kategori = Input::get('kategori'); $data->aktif = Input::get('aktif'); $data->isi = Input::get('isi'); $data->save(); return redirect('/bos/artikel'); } else { return back()->withInput()->with('message', 'Lengkapi data anda terlebih dahulu'); } } }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(HandleUserRequest $request, $userId) { $user = $this->user->findOrFail($userId); $user->update($request->input()); $user->customer()->update($request->input()); return back()->with('success', 'Saved!'); }
public function regenerateCovers($id) { $beatmapset = Beatmapset::findOrFail($id); $job = (new RegenerateBeatmapsetCover($beatmapset))->onQueue('beatmap_processor'); $this->dispatch($job); return back(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request, PaymentRepositoryInterface $payments, TaxCloudRepository $taxCloud) { // $taxCloud = app('TaxCloudRepo'); list($fname, $lname) = explode(' ', $request->input('name'), 2); // This will exception upon a single name. $address = $taxCloud->createAddress($request->address, '', $request->city, $request->state, $request->zipcode); try { $verifiedAddress = $taxCloud->verifyAddress($address); } catch (VerifyAddressException $e) { return back()->withErrors('Unable to verify address.')->withInput(); } if ($verifiedAddress != null) { // We have a USPS verified address $billAddress = $verifiedAddress->getAddress1(); $billCity = $verifiedAddress->getCity(); $billState = $verifiedAddress->getState(); $billZip = $verifiedAddress->getZip5() . '-' . $verifiedAddress->getZip4(); } else { $billAddress = $request->address; $billCity = $request->city; $billState = $request->state; $billZip = $request->zipcode; } $payments->newCard(['cardNumber' => $request->input('number'), 'cardExp' => $request->input('expYear') . '-' . $request->input('expMonth'), 'CVV' => $request->input('CVV'), 'billTo' => ['firstName' => $fname, 'lastName' => $lname, 'address' => $billAddress, 'city' => $billCity, 'state' => $billState, 'zipcode' => $billZip, 'country' => $request->country]], Auth::User()->id); return redirect()->route('settings.billing'); }
public function switchLang($lang) { if ($lang == 'cn' || $lang == 'en') { Session::set('locale', $lang); } return back(); }
function destroy() { $id = Input::get('CITY_ID'); $city = City::findCity($id); $city->delete(); return back(); }
/** * Get a validator for an incoming registration request. * * @param array $data * @return \Illuminate\Contracts\Validation\Validator */ protected function validator(array $data) { return Validator::make($data, ['name' => 'required|max:50|unique:users', 'email' => 'required|email|max:50|unique:users', 'password' => 'required|confirmed|min:6']); if ($validator->fails()) { return back()->withErrors($validator)->withInput(); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$request->user()->admin) { return back()->with('error', 'Not Authorized'); } return $next($request); }
public function uploadImg() { $file = Input::file('file'); if (!$file->isValid()) { return back(); } else { $allowed_extensions = ["png", "jpg", "gif"]; if ($file->getClientOriginalExtension() && !in_array($file->getClientOriginalExtension(), $allowed_extensions)) { return ['error' => '上传失败']; } // 需要填写你的 Access Key 和 Secret Key $accessKey = 'wljtjmpVhsu7OvBBLsU-w-LYtjce9iyMEstqcBXm'; $secretKey = 'EmjQ7c2YlBs42vWPJUiCBzvmCKRRIntV3MBgE_1A'; // 构建鉴权对象 $auth = new Auth($accessKey, $secretKey); // 要上传的空间 $bucket = 'pictures'; // 生成上传 Token $token = $auth->uploadToken($bucket); // 要上传文件的本地路径 $filePath = $file->getRealPath(); // 上传到七牛后保存的文件名 $key = time() . rand(100, 999) . '.jpg'; // 初始化 UploadManager 对象并进行文件的上传 $uploadMgr = new UploadManager(); // 调用 UploadManager 的 putFile 方法进行文件的上传 list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath); if ($err !== null) { return ['error' => '上传失败']; } else { $path = 'http://7xs3aa.com1.z0.glb.clouddn.com/' . $ret['key']; return Response::json(['success' => true, 'pic' => $path]); } } }
public function postLogin(LoginRequest $request) { if (!Auth::attempt(['email' => $request->get('email'), 'password' => $request->get('password')], true)) { session()->flash('errorMessages', ['You have entered an invalid email address or password.', 'Please try again.']); return back()->withInput(); } $user = Auth::user(); // if the user has a plant, set welcome message if (count($user->plants)) { $plant = $user->plants()->where('isHarvested', '=', false)->orderBy(DB::raw('RAND()'))->first(); if ($plant) { // set welcome message to need water or need fertilizer if the plant needs it $lastTimeWatered = $plant->getLastTimeWatered(); $lastTimeFertilized = $plant->getLastTimeFertilized(); $random = round(rand(1, 2)); if (!$lastTimeWatered && $plant->created_at->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_water_phrase_' . $random]; } elseif (!$lastTimeFertilized && $plant->created_at->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_fertilizer_phrase_' . $random]; } elseif ($lastTimeWatered && Carbon::createFromFormat('Y-m-d H:i:s', $lastTimeWatered->pivot->date)->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_water_phrase_' . $random]; } elseif ($lastTimeFertilized && Carbon::createFromFormat('Y-m-d H:i:s', $lastTimeFertilized->pivot->date)->addDay() < Carbon::now()) { $status = $plant->plantCharacter['need_fertilizer_phrase_' . $random]; } else { $status = $plant->plantCharacter['welcome_phrase_' . $random]; } session()->flash('message', $plant->plantCharacter->name . ': ' . $status); } } return redirect()->route('dashboard'); }
public function store(Request $request, Card $card) { $note = new Note(); $note->body = $request->body; $card->notes()->save($note); return back(); }
public function postEstado($id, $estado) { $protocolo = Protocolo::find($id); $protocolo->estado = $estado; $protocolo->save(); return back(); }