Questions tagged [laravel-request]

Laravel Requests - handling request and Request validation

218 questions
1
vote
2 answers

Laravel 5 HTTP/Requests - pass url parameter to the rules() method

I'm trying to create a set of rules under the new \HTTP\Requests\UpdateArticle class for the slug field, which needs to have unique filter applied, but only when the id is not equal the url parameter of the route name article/{article}. What I got…
Sebastian Sulinski
  • 5,815
  • 7
  • 39
  • 61
0
votes
2 answers

Indicate the incorrect key in Laravel's array rule validation error message

I am doing FormRequest validation. I am using the array rule to ensure that only specified keys are allowed in the validated array. For example: $rules = [ 'example' => ['array:something,another'], ]; However, if this rule encounters an array key…
Ari Cooper-Davis
  • 3,374
  • 3
  • 26
  • 43
0
votes
1 answer

Validate IDs in array that are not in a related table

I have an endpoint that accepts and array of IDs in this format: { "data": [ { "id": 1 }, { "id": 2 }, { "id": 4 } ] } ...and in my validation requests file I have:
0
votes
1 answer

How does this form gets the label name of each input

I'm working on some else project which is a Laravel 9 project and I have seen something interesting that have not seen it before. Basically he defined the form inputs of projects like this (example):
Pouya
  • 114
  • 1
  • 8
  • 36
0
votes
1 answer

How to make a field required if it appearing on a form

I have a Laravel 5.8 project and on a Blade I added this: @if(empty($user->usr_name))
*
Pouya
  • 114
  • 1
  • 8
  • 36
0
votes
0 answers

Laravel validation error message show only short form

I got used to request to validate before entering the API side function itself, but recently, when I moved the controller function to services then, the error message became like the below sample. { "message": "validation.min.string", …
Dirty Rex
  • 13
  • 4
0
votes
1 answer

add $request parameter to wordpress api callback like laravel

As you know you can create a new Request in laravel and pass it to controller methods, like so: public function create(CreateNewBookRequest $request){ //todo method logic } now I want to implement such a thing in wordpress REST API. As you know…
0
votes
0 answers

how to add laravel conditional validation

I want to add conditional validation to my request. I have different user roles and different fields for some users. I want to check if the user role is business then some fields are required and if the user is a worker then business user fields are…
0
votes
2 answers

how to unique data group validation in form request laravel

I have two column 'book_name' & 'writer' in 'books' table. When new data insert i want to check the same book and writer not will be added. But i dont understand how to do this. here is my code. public function rules() { return [ …
mahbub
  • 103
  • 1
  • 3
  • 13
0
votes
0 answers

Laravel Request Class prepareForValidation not reflected in $request->get

In a API endpoint taking "emails" as an array, I am validating values with a Request Class. In this Request class' prepareForValidation method: $this->merge([ 'emails' => array_unique($this->emails) ]); I have this lines. And a controller like…
Alper
  • 152
  • 1
  • 7
0
votes
1 answer

Laravel Ignore not working for unique validation rule

I'm working on a simple API using Laravel. At the moment working on the update endpoint for my categories resource. A name for a category must be unique and that seems to be working just fine, but when performing an update it is failing even though…
MrCujo
  • 1,218
  • 3
  • 31
  • 56
0
votes
1 answer

How to add required if validation rule if a file has been uploaded

I'm working with Laravel 5.8 and here is my validation request form: public function rules() { return [ 'art_audio_file' => ['nullable', 'file', 'mimes:audio/mpeg,mpga,mp3,wav,aac'], 'art_audio_file_title' =>…
Pouya
  • 114
  • 1
  • 8
  • 36
0
votes
3 answers

How to fix search request query problem with multiple form fields

I'm working with Laravel 8 and at users.blade.php where all of the users of the website appears, I wanted to add a search form for searching the names, mobile number & other information related to a user:
japose7523
  • 29
  • 2
  • 15
0
votes
2 answers

why $request->has(' ') not working in laravel?

i am using laravel framework ,for testing API's i am using postman.i have one registration api which receives an input and storing the data based on some checks ,it's not passing the condition of $request->has('phone') can you please help me how to…
Code cracker
  • 316
  • 1
  • 5
  • 20
0
votes
3 answers

Laravel request remove fields before validation

I am trying to remove some fields before they are validated. Trying to attempt this inside prepareForValidation() use Illuminate\Foundation\Http\FormRequest; class VideoRequest extends ApiRequest { // ..code.. protected function…
The Blind Hawk
  • 1,199
  • 8
  • 24