Laravel Requests - handling request and Request validation
Questions tagged [laravel-request]
218 questions
2
votes
2 answers
automatically failing custom request in laravel
I have created a custom request that needs to check a variable before proceeding forward. This is my CustomRequest and have something like this
class CustomRequest extends FormRequest
{
public function rules(){
if ($variable == "abc")…

Ali Rasheed
- 2,765
- 2
- 18
- 31
2
votes
3 answers
Using complex conditional validation rule in FormRequest in Laravel
I am developing a Web application using Laravel. What I am doing now is creating a FirmRequest for the validation.
This is my FormRequest.
use Illuminate\Foundation\Http\FormRequest;
class StoreVacancy extends FormRequest
{
public function…

Wai Yan Hein
- 13,651
- 35
- 180
- 372
2
votes
1 answer
How to remove an existing item from a route request parameters? - Laravel 5.5
I want to remove an existing item from a request parameters that passes in a controller.
Here's my controller:
public function getIndex(Request $request)
{
// I need to remove a parameter from the $request here.
}
Actually, I want to dispatch…

Behnam Azimi
- 2,260
- 3
- 34
- 52
2
votes
1 answer
Need to include input at top in all controller laravel
Hi in my project there are many controllers and i want use input everywhere without including in controller at top like this
use Illuminate\Support\Facades\Input; //or
use Input; // if i create alias for the same in app.php
is there any way that…

Darshan ambaliya
- 301
- 3
- 20
2
votes
4 answers
Transform Request to custom validation request
Is it possible to transform Illuminate\Http\Request to custom validation request you made with php artisan make:request MyRequest?
I would like validation to take place in a method down the road so that I have:
protected function register(Request…

Norgul
- 4,613
- 13
- 61
- 144
2
votes
1 answer
Migration to Laravel, Vanity URLs, middleware for all requests, Auth::user and $errors issue
I created a middleware class named PathParser which runs on every request. The purpose is to handle requests for "vanity URL paths" that we allowed users to create in our pre-Laravel vanilla PHP app. For example: A user created a URL path such as:…

udog
- 1,490
- 2
- 17
- 30
2
votes
1 answer
Can I refactor out an "unused" $request variable in a controller?
Let's say I'm building a small application, where a small part of it is responsible for sending an email when a contact form is submitted. I only want to do that if the contact form passes some simple validation.
In the following controller the…

Joe
- 15,669
- 4
- 48
- 83
2
votes
3 answers
Laravel : How to orderBy on a One to One inverse relationship
I have a Asset model and AssetCategory model. The asset model has function
$this->belongsTo('App\AssetCategory' ); //inverse one to one
My assets table has columns id , name , assetcategory_id .
Now, when I want to populate my assets list and…

Bit One
- 41
- 4
2
votes
0 answers
Laravel sometimes and require rule unexpected behaviour
I working on Laravel application. In UserRequest I am validating the input. The following rule:
'name' => 'sometimes|required|string|min:2|max:50'
fails if user name is not present although there is sometimes keyword present. The following request…

Dmitry Torba
- 3,004
- 1
- 14
- 24
2
votes
0 answers
Laravel 5.2 different validation rules based on another field value inside request class
Here is what I'm trying to accomplish, I have a form that has a dropdown field of types, lets say type1, type2, type3, and I have a textfield, I want to make the rule for the textfield depend on the type, for example if the type is type1 then the…

Tariq Qubti
- 43
- 1
- 6
2
votes
2 answers
Laravel 5.2 - extending the Validator class
I am trying to override the doReplacements method in Illuminate\Validation\Validator. When I extend the native Validator and Request classes, I get this error:
ReflectionException in Route.php line 270:
Class App\Http\Requests\FooRequest does not…

brietsparks
- 4,776
- 8
- 35
- 69
2
votes
1 answer
Laravel: Use two Requests at the same time in a controller
I have a function in my controller. The problem is I must use two Requests at the same time but only one of them can be used in a controller.
Illuminate\Support\Facades\Request
Illuminate\Http\Request
Code:
public function func(Request $req) {
…

Mahmood Kohansal
- 1,021
- 2
- 16
- 42
2
votes
0 answers
Laravel Validator AND / require a field ONLY if both conditions are met
Using Laravel 5.1, is there a way to require a field ONLY if both conditions are met?
In the code example below, in the rules, I have field2_en and field2_de. I put 2 required_if rules for each field, the field becomes required if 1 of the 2 OR both…

Martin
- 137
- 1
- 13
2
votes
3 answers
How to use custom validation attributes on an array of inputs
I'm using Laravel to build a form that contains an array of inputs and I’m having difficulty in showing the translated attribute name when a validation error occurs. For simplicity sake I will post a simple example of my problem.
Form inside the…

user3155378
- 21
- 1
- 2
2
votes
0 answers
Dropzonejs with Laravel 5 (Request does not get any data)
I have been trying to implement a dropzone file upload module with Laravel 5.
The problem is that when a file is uploaded dropzone sends the full request to the file upload controller, however, the controller does not get any data.
What am I…

Wheel Barrow
- 36
- 5