PHP illuminate\http Request Examples

PHP illuminate\http Request - 30 examples found. These are the top rated real world PHP examples of illuminate\http\Request extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($returnUrl = $request->input('return')) {
         $request->session()->put('url.intended', $returnUrl);
     }
     return $next($request);
 }
Example #2
0
 /**
  * Convert an authentication exception into an unauthenticated response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Auth\AuthenticationException  $exception
  * @return \Illuminate\Http\Response
  */
 protected function unauthenticated($request, AuthenticationException $exception)
 {
     if ($request->expectsJson()) {
         return response()->json(['error' => 'Unauthenticated.'], 401);
     }
     return redirect()->guest('login');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $permissions
  * @return mixed
  * @internal param $roles
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $permissions)
 {
     if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
         abort(403);
     }
     return $next($request);
 }
Example #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->service->update($request->all());
     $file = File::find($this->service->file_id);
     $file->update(['name' => $request['file']]);
     return "Actualizado";
 }
 public function intlDomain(Request $request)
 {
     $data = $request->all();
     $contacts = (object) $data['contacts'];
     //Registrant Contact Array
     $registrant = ['Firstname' => $contacts->Registrant_FirstName, 'Lastname' => $contacts->Registrant_LastName, 'Organization' => 'My Company', 'CountryCode' => $contacts->Registrant_CountryCode, 'City' => $contacts->Registrant_City, 'Email' => $contacts->Registrant_Email, 'Street' => $contacts->Registrant_Street, 'PostalCode' => $contacts->Registrant_PostalCode, 'PhoneNumber' => $this->intlphoneNumber($contacts->Registrant_PhoneNumber, $contacts->Registrant_CountryCode)];
     // Admin Contact Array
     $admin = ['Firstname' => $contacts->Admin_FirstName, 'Lastname' => $contacts->Admin_LastName, 'Organization' => 'My Company', 'CountryCode' => $contacts->Admin_CountryCode, 'City' => $contacts->Admin_City, 'Email' => $contacts->Admin_Email, 'Street' => $contacts->Admin_Street, 'PostalCode' => $contacts->Admin_PostalCode, 'PhoneNumber' => $this->intlphoneNumber($contacts->Registrant_PhoneNumber, $contacts->Registrant_CountryCode)];
     $c = array('Registrant' => $registrant, 'Admin' => $admin, 'Technical' => $admin, 'Billing' => $admin);
     $nameservers = ['Ns_list' => implode(',', $data['name_servers'])];
     try {
         InternetBS::init('X1A7S0D7X8N0U0U0I6S2', 'Toto197500cxz');
         if (Domain::find($data['domain_id'])->domain_status == 0) {
             $response = (object) json_decode(InternetBS::api()->domainCreate($data['domain_name'], $c, 1, $nameservers));
             if ($response->product[0]->status == 'SUCCESS') {
                 $domain = Domain::find($data->domain_id);
                 $domain->domain_status = 1;
                 $domain->save();
                 // Send an email of confirmation and do a redirection automatically
                 return redirect('admin/dashboard');
             } else {
                 // Redict to error page
                 return redirect('admin/errors');
             }
         } else {
             // Update Domain Name //
             InternetBS::api()->domainAssignNS($data['domain_name'], $data['name_servers']);
             $updates = InternetBS::api()->domainUpdate($data['domain_name'], $c);
             return ['response' => $updates];
         }
     } catch (Exception $e) {
         return ['response' => 'error detected', 'error_msg' => $e->getMessage()];
     }
 }
 public function notdone(Request $request, DoneTask $task)
 {
     $request->user()->tasks()->create(['name' => $request->name]);
     $this->authorize('destroy', $task);
     $task->delete();
     return redirect('/tasks');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $hunt = $request->all();
     $hunt['user_id'] = Auth::user()->id;
     Hunt::create($hunt);
     return redirect('/home');
 }
 public function doRegister(Request $request)
 {
     $validator = Validator::make($data = $request->all(), Admin::$rules, Admin::$messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if ($validator->passes()) {
         $confirmation_code = Str::quickRandom(30);
         $admin = new Admin();
         $admin->fullname = ucwords($request->fullname);
         $admin->mobile_no = $request->mobile_no;
         $admin->email = $request->email;
         $admin->password = bcrypt($request->password);
         $admin->confirmation_code = $confirmation_code;
         $data = ['confirmation_code' => $confirmation_code, 'username' => $request->username, 'password' => $request->password, 'mobile_no' => $request->mobile_no];
         Basehelper::sendSMS($request->mobile_no, 'Hello ' . $request->username . ', you have successfully registere. Your username is ' . $request->username . ' and password is ' . $request->password);
         // Mail::send('emails.verify', $data, function($message) use ($admin, $data){
         // 	$message->from('no-reply@employment_bank', 'Employment Bank');
         //     	$message->to(Input::get('email'), $admin->name)
         //         	->subject('Verify your email address');
         // });
         if (!$admin->save()) {
             return Redirect::back()->with('message', 'Error while creating your account!<br> Please contact Technical Support');
         }
         return Redirect::route('admin.login')->with('message', 'Account has been created!<br>Now Check your email address to verify your account by checking your spam folder or inboxes for verification link after that you can login');
         //sendConfirmation() Will go the email and sms as needed
     } else {
         return Redirect::back()->withInput()->withErrors($validation);
         // ->with('message', 'There were validation errors.');
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->user()->isADoctor()) {
         return redirect('dash');
     }
     return $next($request);
 }
Example #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $todo = auth()->user()->employee->todos()->create($request->all());
     if ($todo) {
         return $todo;
     }
 }
Example #11
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $loggingIn = $request->is('api/v1/login') || $request->is('api/v1/register') || $request->is('api/v1/oauth_login');
     $headers = Utils::getApiHeaders();
     $hasApiSecret = false;
     if ($secret = env(API_SECRET)) {
         $requestSecret = Request::header('X-Ninja-Secret') ?: ($request->api_secret ?: '');
         $hasApiSecret = hash_equals($requestSecret, $secret);
     }
     if ($loggingIn) {
         // check API secret
         if (!$hasApiSecret) {
             sleep(ERROR_DELAY);
             return Response::json('Invalid value for API_SECRET', 403, $headers);
         }
     } else {
         // check for a valid token
         $token = AccountToken::where('token', '=', Request::header('X-Ninja-Token'))->first(['id', 'user_id']);
         // check if user is archived
         if ($token && $token->user) {
             Auth::onceUsingId($token->user_id);
             Session::set('token_id', $token->id);
         } else {
             sleep(ERROR_DELAY);
             return Response::json('Invalid token', 403, $headers);
         }
     }
     if (!Utils::isNinja() && !$loggingIn) {
         return $next($request);
     }
     if (!Utils::hasFeature(FEATURE_API) && !$hasApiSecret) {
         return Response::json('API requires pro plan', 403, $headers);
     } else {
         $key = Auth::check() ? Auth::user()->account->id : $request->getClientIp();
         // http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users
         $hour = 60 * 60;
         $hour_limit = 100;
         # users are limited to 100 requests/hour
         $hour_throttle = Cache::get("hour_throttle:{$key}", null);
         $last_api_request = Cache::get("last_api_request:{$key}", 0);
         $last_api_diff = time() - $last_api_request;
         if (is_null($hour_throttle)) {
             $new_hour_throttle = 0;
         } else {
             $new_hour_throttle = $hour_throttle - $last_api_diff;
             $new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle;
             $new_hour_throttle += $hour / $hour_limit;
             $hour_hits_remaining = floor(($hour - $new_hour_throttle) * $hour_limit / $hour);
             $hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
         }
         if ($new_hour_throttle > $hour) {
             $wait = ceil($new_hour_throttle - $hour);
             sleep(1);
             return Response::json("Please wait {$wait} second(s)", 403, $headers);
         }
         Cache::put("hour_throttle:{$key}", $new_hour_throttle, 10);
         Cache::put("last_api_request:{$key}", time(), 10);
     }
     return $next($request);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input.
     $questionstatus = Questionstatuses::findOrFail($id);
     $questionstatus->update($request->all());
     return redirect('questionstatus');
 }
Example #13
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $evento = EventoModel::findOrFail($id);
     $input = $request->all();
     $evento->fill($input)->save();
     return redirect('/evento');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CookieJar $cookieJar, Request $request)
 {
     if ($request->isMethod('post')) {
         $supplier_email = $request->get('supplier_email');
         $supplier_password = $request->get('supplier_password');
         $checkAgentExists = Supplier::where("email", "=", $supplier_email);
         $checkAgentExists = $checkAgentExists->where("password", "=", md5($supplier_password . Config::get('constants.SITENAME')));
         $checkAgentExists = $checkAgentExists->get();
         if ($request->get('remember_login')) {
             $cookieJar->queue(Cookie::make('supplier_email', $supplier_email, 60));
             $cookieJar->queue(Cookie::make('supplier_password', $supplier_password, 60));
         } else {
             $cookieJar->queue(Cookie::forget('supplier_email'));
             $cookieJar->queue(Cookie::forget('supplier_password'));
         }
         if (count($checkAgentExists) > 0) {
             Session::put('SUPPLIER_ACCESS_ID', $checkAgentExists[0]->id);
             Session::put('SUPPLIER_ACCESS_FNAME', $checkAgentExists[0]->first_name);
             Session::put('SUPPLIER_ACCESS_LNAME', $checkAgentExists[0]->last_name);
             return redirect('supplier/dashboard');
         } else {
             return Redirect::route('supplier_land')->with('message', ['Invalid email address or/and password.']);
         }
     }
 }
Example #15
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string $role
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (!$request->user()->hasRole($role)) {
         return redirect()->back()->withErrors('msg', 'Not authorized');
     }
     return $next($request);
 }
Example #16
0
 protected function processMany(Request $request, $id, $method)
 {
     $parent = $this->findParentEntity($id);
     $requestCollection = $request->json()->all();
     $this->validateRequestCollection($requestCollection, $this->getChildModel(), true);
     $existingChildren = $this->findChildrenCollection($requestCollection, $parent);
     $childModels = $this->fillModels($this->getChildModel(), $existingChildren, $requestCollection);
     $this->checkPermission(static::class . '@' . $method . 'Many', ['model' => $parent, 'children' => $childModels]);
     $this->preSync($parent, $childModels);
     $this->saveNewItemsInCollection($childModels);
     /** @var ElasticSearchIndexer $searchIndexer */
     $searchIndexer = app(ElasticSearchIndexer::class);
     $reindexItems = $searchIndexer->mergeUniqueCollection($searchIndexer->getAllItemsFromRelations($parent, [$this->relationName]), $childModels);
     $this->getRelation($parent)->{$method}($this->makeSyncList($childModels, $requestCollection));
     $this->postSync($parent, $childModels);
     // Reindex parent entity without relations
     $searchIndexer->reindexOne($parent, []);
     // Reindex all affected items without relations
     $searchIndexer->reindexMany($reindexItems, []);
     $transformed = $this->getTransformer()->transformCollection($this->findAllChildren($parent), ['_self']);
     $responseCollection = collect($transformed)->map(function ($entity) {
         return ['_self' => $entity['_self']];
     })->toArray();
     return $this->getResponse()->collection($responseCollection, ApiResponse::HTTP_CREATED);
 }
 public function store(Request $request)
 {
     $postCategory = $request->get('postCategory');
     if ($postCategory == "create") {
         $moduleDetails = BaseHelpers::createModule($request->file('file'));
         $module = ModvelModule::create(['name' => $moduleDetails["name"], 'description' => $moduleDetails["description"], 'category' => $moduleDetails["category"], 'customer' => $moduleDetails["customer"], 'icon' => $moduleDetails["icon"], 'version' => $moduleDetails["version"], 'adminDisplayName' => $moduleDetails["adminDisplayName"], 'adminVisible' => $moduleDetails["adminVisible"], 'adminDisplayOrder' => 0, 'displayName' => $moduleDetails["displayName"], 'displayVisible' => $moduleDetails["displayVisible"], 'displayOrder' => $moduleDetails["displayOrder"]]);
         foreach ($moduleDetails as $k => $v) {
             if (is_array($v)) {
                 if ($v != []) {
                     foreach ($v as $key => $value) {
                         $detail = new ModvelModuleDetail();
                         $detail->moduleId = $module->id;
                         $detail->category = $k;
                         $detail->key = $key;
                         $detail->value = $value;
                         $detail->save();
                     }
                 }
             }
         }
         $datas = ModvelModule::get();
         return view("Modvel::admin." . $this->theme . ".modules.index")->with('datas', $datas)->with('headName', $this->headName);
     }
     $datas = ModvelModule::get();
     return view("Modvel::admin." . $this->theme . ".modules.index")->with('datas', $datas)->with('headName', $this->headName);
 }
 /**
  * Update the specified resource in storage.
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $feedUpdate = $request->all();
     $feed = Feed::find($id);
     $feed->update($feedUpdate);
     return redirect('feed');
 }
Example #19
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //validate this
     var_dump($request->all());
     $input = $request->all();
     $params = [];
     $quantities = $input['quantities'] = explode(',', $input['quantities']);
     $items = $this->item->getIn('id', explode(',', $input['ids']));
     $ctr = 0;
     $recipe = Recipe::create($request->all());
     foreach ($items as $key => $value) {
         $ing = ['name' => $value['name'] . " for " . $recipe->name, 'recipe_id' => $recipe->id, 'item_id' => $value['id'], 'quantity' => (int) $quantities[$ctr]];
         array_push($params, $ing);
         $ctr++;
     }
     $ingredients = Ingredient::insert($params);
     if ($recipe && $ingredients) {
         return redirect()->back()->with('flash_message', 'Recipe has been successfully saved.');
     }
     $this->recipe->fdelete($recipe);
     foreach ($ingredients as $key) {
         $key->forceDelete();
     }
     return redirect()->back()->withErrors('Could not save recipe');
 }
Example #20
0
 public function index(Request $request)
 {
     $orderby = empty(trim($request->get('orderby'))) ? 'id' : $request->get('orderby');
     $order = empty(trim($request->get('order'))) ? 'asc' : $request->get('order');
     $data = ['title' => 'Quản lý ngôn ngữ', 'items' => $items = $this->lang->getAll(['*'], null, $orderby, $order)];
     return view('backend.language.index', $data);
 }
Example #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $message = null;
     if ($this->validator($request->all())->fails()) {
         flash()->error('Please fill all the required field!');
         return redirect()->back()->withInput();
     }
     if ($this->user->email) {
         $employee = $this->user->employee;
         $sender = ['email' => $this->user->email, 'name' => $employee ? $employee->fullName() : $this->user->username];
         $recipient = $request->recipient;
         $message = Mail::raw($request->content, function ($msg) use($request, $sender) {
             $msg->from($sender['email'], $sender['name']);
             $msg->to($request->recipient);
             $msg->subject($request->subject);
             $request->cc ? $message->cc($request->cc) : null;
             $request->bcc ? $message->cc($request->bcc) : null;
         });
     }
     if ($message) {
         flash()->success('Message successfully sent!');
     } else {
         flash()->error('Message not sent!');
     }
     return redirect()->back();
 }
Example #22
0
 public function createSchema(Request $request)
 {
     $req_id = $this->createReq();
     $data = $request->all();
     // print_r($data);
     $this->createBP($data, $req_id);
     $this->createST($data, $req_id);
     if (!isset($data['theme_id'])) {
         $theme_id = $this->saveTheme($data['theme_name']);
     } else {
         $theme_id = $data['theme_id'];
     }
     if (!isset($data['schema_id'])) {
         $schema = $this->saveSchema($data['schema_name'], "00");
     } else {
         $schema = $data['schema_id'];
     }
     $classes = $data['classes'];
     //$classes = array_reverse($data['classes']);
     $classes = $this->sortClasses($classes);
     foreach ($classes as $d) {
         $this->createClass($d, $schema, $theme_id, $req_id);
     }
     $this->updateSchema($schema, '01');
     return '';
     //$classes = $request->all();
 }
 public function index(Request $request)
 {
     $type = $request->get('type');
     $q = $request->get('q');
     $search = new Search();
     return ['type' => $type, 'items' => $search->search($q, $type)];
 }
 public function postDelete(Request $request)
 {
     $id = intval($request->all()["id"]);
     $article = $this->article->find($id);
     $article->delete();
     return redirect()->to('/ln-admin/articles');
 }
Example #25
0
 /**
  * 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 $next($request);
     }
     return new RedirectResponse(url('post/liste'));
 }
Example #26
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $task = Task::findOrFail($id);
     $input = $request->all();
     $task->fill($input)->save();
     return view('pages.dashboard')->with('users', User::all())->with('task_categories', TaskCategory::all())->with('tasks', Task::all());
 }
 public function create(Request $data)
 {
     $validator = Validator::make($data->all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         $this->throwValidationException($data, $validator);
     }
     $user = new User();
     $activation_code = str_random(60) . $data['email'];
     $user->name = $data['name'];
     $user->email = $data['email'];
     $user->password = bcrypt($data['password']);
     $user->how_know = $data['how_know'];
     $user->activation_code = $activation_code;
     if ($user->save()) {
         $to = $data['email'];
         // subject
         $subject = 'Verification Required';
         // message
         $message = "\n\t\t\t\t<div style='line-height:1'>\n\t\t\t\t\t<div style='width:700px;margin:0 auto;margin-top:20px;padding:0px;background:#f5f5f5;border:1px solid #d2d2d2;border-radius:5px;font-family:Arial,Helvetica,sans-serif'>\n\t\t\t\t\t<div style='width:700px;margin:0px;padding:20px 0px 20px 0px;background:url(https://ci4.googleusercontent.com/proxy/U9DVvzyQQifr6SPalG_Od_DoppU3VoTGQ_PsL0zGu6CNvmYzsnGQ6kaGbuRdwluMALk7IZCWqMOxM-XtCO772qA7_Zqx=s0-d-e1-ft#{{url('images/logo.png')}}) top left repeat;border-radius:5px 5px 0px 0px;text-align:center'><img src='{{url('images/logo.png')}}' ></div>\n\t\t\t\t\t    <div style='width:660px;margin:10px 0px 0px 0px;padding:20px;font-size:12px;color:#262626;line-height:18px'>\n\t\t\t\t\t    \t<p>Dear  <a href='mailto:premsingh57@gmail.com' target='_blank'>premsingh57@gmail.com</a>,</p>\n\t\t\t\t\t        <p>You are receiving this email because you are requested to  create new account on Omni Text Solution. Please click on the link below to complete your confirmation.</p>\n\n\t\t\t\t\t\t\t<div style='text-align:center;padding:10px 0px'><a style='font-size:14px;font-weight:bold;color:#fff;background:#2dcc70;text-decoration:none;border-radius:5px;padding:8px 15px' target='_blank'>Confirm</a></div>\n\n\t\t\t\t\t\t\t<p>If you think that you shouldn't have received this email, you can safely ignore it.</p>\n\n\t\t\t\t\t\t\t<p>Thank you,</p>\n\t\t\t\t\t\t\t<p>Omni Text Solution</p><div></div><div >\n\t\t\t\t\t    \t\n\t\t\t\t\t    </div></div></div>\n\t\t\t\t</div>\n\t\t\t";
         // To send HTML mail, the Content-type header must be set
         $headers = 'MIME-Version: 1.0' . "\r\n";
         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
         $headers .= "From: donotreply@omnitext.com" . "\r\n";
         mail($to, $subject, $message, $headers);
         \Session::flash('success_message', "Activation link is send to {$data['email']}. Please activite your account");
         return view('auth.register');
     }
 }
 public function facebooklogin(Request $request)
 {
     $user = User::where('email', '=', $request->input('email'))->first();
     var_dump($user);
     if ($user) {
         echo 'exists';
     } else {
         echo '!!!!exists';
     }
     if (!$user) {
         // return 'no user';
         $newUser = new User();
         $newUser->name = $request->input('name');
         $newUser->surname = $request->input('surname');
         $newUser->email = $request->input('email');
         $newUser->ip = $request->getClientIp();
         $newUser->is_facebook = true;
         $newUser->isAdmin = 0;
         $newUser->residcence = "";
         $newUser->address = "";
         $newUser->save();
         Auth::login($newUser);
     } else {
         Auth::login($user);
     }
     return $user;
 }
Example #29
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     dd(1111);
     $advert = new Advert();
     $advert->create($request->all());
     return redirect()->route('/');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @param $role
  * @return mixed
  */
 public function handle($request, Closure $next, $role)
 {
     if (!$request->user()->is($role)) {
         return redirect()->back()->withErrors('You have no permissions to open this URL');
     }
     return $next($request);
 }