laravel-request

How to redirect on register page if otp verified otherwise redirect to login Laravel?

本小妞迷上赌 提交于 2021-01-05 07:25:48
问题 I am using Laravel 8 and Firebase to verify mobile with OTP. Now I want that if OTP verified then i can access register page if OTP is not verified then redirect to login page. Now I am using default Laravel registration form and when OTP verified i stored in cookie. I have created middleware but its not work if cookie not set then also i access registration but i want it not accessable. Middle-ware code is, public function handle(Request $request, Closure $next) { if (Cookie::get(

How i can return a customized response in a FormRequest class in Laravel 5.5?

风格不统一 提交于 2020-03-18 04:00:30
问题 I am making an API and i want return the array of errors with a format as the one that $validator->errors(); generates when i validate the request by the manual way. But i cant manipulate the response. I wanna find thhe correct way to make it. This could be done in Laravel 5.4 with the formatErrors method and including the Illuminate\Contracts\Validation\Validator class in the FormRequest class but for version 5.5 it does not work. I do not know how to do it. This is my Controller: <?php

Laravel request validation with multiple forms on the same page

血红的双手。 提交于 2020-01-24 07:49:32
问题 I have three different forms on the same page. All inputs has it's own validation rules, code in Request file has structure like this: public function rules() { return [ // 'sold' => 'required', 'unit_in_stock' => 'required', 'unit_price_gbp' => 'required', 'returned_item' => 'required', ]; } public function messages() { return [ 'sold.required' => 'Please enter quantity of sold parts', 'unit_in_stock.required' => 'Please enter quantity of sold parts', 'unit_price_gbp.required' => 'Please

Laravel request validation with multiple forms on the same page

半腔热情 提交于 2020-01-24 07:49:09
问题 I have three different forms on the same page. All inputs has it's own validation rules, code in Request file has structure like this: public function rules() { return [ // 'sold' => 'required', 'unit_in_stock' => 'required', 'unit_price_gbp' => 'required', 'returned_item' => 'required', ]; } public function messages() { return [ 'sold.required' => 'Please enter quantity of sold parts', 'unit_in_stock.required' => 'Please enter quantity of sold parts', 'unit_price_gbp.required' => 'Please

Laravel 5 Request - altering data

半腔热情 提交于 2020-01-23 07:06:28
问题 I have come across an instance where I need to alter the data that needs to be validated i.e. when no slug has been submitted, create one from the title and then validate that it is unique. The request has a method replace() which is supposed to replace the input data on the request but it doesn't appear to work. Can anyone shine a light on this? This is what I have: <?php namespace Purposemedia\Pages\Http\Requests; use Dashboard\Http\Requests\Request; use Illuminate\Auth\Guard; class

How to retrieve a url parameter from request in Laravel 5?

核能气质少年 提交于 2019-12-12 11:13:05
问题 I want to perform certain operations with a model in a middleware. Here is an example of what I want to achieve: public function handle($request, Closure $next) { $itemId = $request->param('item'); // <-- invalid code, serves for illustration purposes only $item = Item::find($itemId); if($item->isBad()) return redirect(route('dont_worry')); return $next($request); } My question is, how can I retrieve the desired parameter from the $request ? 回答1: public function handle(Request $request,

Laravel - BindingResolutionExceptionUnresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttp\Psr7\Request

寵の児 提交于 2019-12-12 04:31:05
问题 I'm unable to accept post request in Laravel because of following exception BindingResolutionException in Container.php line 819: Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttp\Psr7\Request Before occurance of this error I just made routes for authentication, php artisan make:auth I'm using Laravel 5.4, PHP 5.6.25, Apache 2.4.23 Thanks in anticipation 来源: https://stackoverflow.com/questions/42808138/laravel-bindingresolutionexceptionunresolvable

Object of class Illuminate\Validation\Validator could not be converted to string

跟風遠走 提交于 2019-12-12 01:37:45
问题 I'm yet to understand what needed to be fixed in the code making it to generate the error. What is to be put right? This is the code: public function store(Request $request){ $validator = Validator::make($request->all(), [ 'user_id' => 'required|numeric', 'company_id' => 'required|numeric', 'product_id' => 'required|numeric', 'tankerTotankerDesc' => 'alpha_num|min:5', 'tankerTakeOverDesc' => 'alpha_num|min:5', 'costFreightInsuranceDesc' => 'alpha_num|min:5', 'freightOnBoardDesc' => 'alpha_num

How to Use custom request (make:request)? (laravel) Method App\Http\Requests\Custom::doesExistI does not exist

可紊 提交于 2019-12-11 22:03:27
问题 I created a custom request to make my own validation. As i follow these article. I created ProfileRequest php artisan make:request ProfileRequest Inside my ProfileRequest <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class ProfileRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array

Laravel Request getting current path with query string

拥有回忆 提交于 2019-12-09 04:06:29
问题 Is there a Laravel way to get the current path of a Request with its query parameters? For instance, for the URL: http://www.example.com/one/two?key=value Request::getPathInfo() would return /one/two . Request::url() would return http://www.example.com/one/two . The desired output is /one/two?key=value . 回答1: Try to use the following: \Request::getRequestUri() 回答2: Request class doesn't offer a method that would return exactly what you need. But you can easily get it by concatenating results