本文整理汇总了PHP中Illuminate\Http\Request类的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notdone
public function notdone(Request $request, DoneTask $task)
{
$request->user()->tasks()->create(['name' => $request->name]);
$this->authorize('destroy', $task);
$task->delete();
return redirect('/tasks');
}
示例2: intlDomain
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()];
}
}
示例3: doRegister
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.');
}
}
示例4: handle
/**
* 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);
}
示例5: handle
/**
* 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);
}
示例6: handle
/**
* 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);
}
示例7: update
/**
* 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";
}
示例8: unauthenticated
/**
* 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');
}
示例9: store
/**
* 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');
}
示例10: store
/**
* 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;
}
}
示例11: handle
/**
* 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);
}
示例12: update
/**
* 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');
}
示例13: update
/**
* 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');
}
示例14: store
/**
* 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.']);
}
}
}
示例15: handle
/**
* 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);
}