Laravel Requests - handling request and Request validation
Questions tagged [laravel-request]
218 questions
6
votes
1 answer
Laravel 5 Request - altering data
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…

Luke Snowden
- 4,056
- 2
- 37
- 70
5
votes
1 answer
Laravel 5.8 Custom Form Request not working as intended?
I created a custom form request named ClientStoreRequest with the following code:

Andy Holmes
- 7,817
- 10
- 50
- 83
5
votes
3 answers
Laravel 5.6 Api - Search,sort and filter on list of data
Hi I am developing a rest api endpoint for retrieving paginated list of users. In the frontend, there are options to search with all the listed columns, sort by all columns and filter by name, status and created date.
So far I have created a…

Zammuuz
- 708
- 4
- 18
- 43
5
votes
3 answers
Laravel 5 Form request, require input on create, but optional on edit
I am using laravel 5.6 resources controllers and form request the problem is that i have some inputs that are required on created, but on edit are optionals like file inputs. So i have this form request

Carlos Salazar
- 1,818
- 5
- 25
- 48
5
votes
2 answers
Laravel request validation with multiple forms on the same page
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' =>…

bohdan baida
- 389
- 1
- 5
- 20
5
votes
2 answers
LARAVEL 5.0 + Unit Test - assertSessionHasErrors with different bags
I am writing a unit test in Laravel 5.0 and in my request class I am using a different bag to show the validation error messages.
I am using this in my file:
/* ExampleRequest.php */
namespace App\Http\Requests;
use App\Http\Requests\Request;
use…

giordanolima
- 1,190
- 1
- 12
- 21
5
votes
1 answer
Request::getQueryString() without some parameters
I am using the following code to append the query strings with two links. But I want to exclude the page parameter of pagination from the query string.
Teachers

Hassan Saqib
- 2,597
- 7
- 28
- 51
4
votes
2 answers
Laravel How to send parameters to view after validation on automatic redirect
I have two forms on two tabs, my problem is when I have selected the second tab and send my form, if it has some errors it redirects me back but on tab one instead of two, so I created a variable that controls in which tab should be showing on…

Sociopath
- 295
- 2
- 14
4
votes
4 answers
Best way to validate Laravel Requests
In my Resource Controller I have a store and an update function with nearly the same validation rules. Because my validation is a bit more complicated I created a Request for this.
But because the validation rules differ a bit, I have to create two…

no0by5
- 632
- 3
- 8
- 30
4
votes
1 answer
Error: Call to a member function storeAs() on string
public function cadastraAutomovelHomeAdd(Request $request)
{
$file = $request->arquivo;
$upload = $request->arquivo->storeAs('products', 'novonomeaffffff.jpg');
exit();
}
Form
4
votes
2 answers
Laravel 5.7 - Override all() method in Request validation Class to validate route parameters?
I want to validate the route parameters in the Request validation class. I know this question has been asked many times before but According to this question I override all() method and I receive this error:
Class…

Ali Hesari
- 1,821
- 5
- 25
- 51
4
votes
1 answer
How to exclude all the data that fail validation laravel?
I only want the data that pass the validation. And do not want any errors or redirection using laravel-validation. So far I've been able to stop the redirection using a laravel-request but the validation does not seem to work properly if I leave the…

Anish Silwal
- 980
- 1
- 10
- 24
4
votes
3 answers
Customize Laravel API validation responses
I'm building a REST API with Laravel and wondering if there is a way to customize the API responses when validating.
For example, I have a validation rule in a Laravel request, saying a specific field is required.
public function rules() {
…

Tharindu Thisarasinghe
- 3,846
- 8
- 39
- 70
4
votes
1 answer
Login and registration form in Laravel 5
I start to learn a new laravel and trying to learn it, by building small project, to make my starter site, but I have a problem. I only create new project without any plugin.
I have a problem with login and register form. I put this into route…

mrakodol
- 1,143
- 3
- 12
- 41
3
votes
0 answers
Why do we we pass $request to toArray() if we dont use it?
I am new to Laravel. I am currently building a resource. I was just wondering what is the purpose of passing in the $request object if we use the $this variable when using resources. Below is an example of my code.
class PetitionResource extends…

json2021
- 2,146
- 2
- 14
- 28