101 questions
0
votes
1
answer
53
views
Laravel 10: getting 404 Not Found on a POST route when using Form Request Validation
Within a Laravel project, I want to create a POST /movies route associated with a controller that has been created with its model:
sail artisan make:model --controller --api --requests -- Movie
which ...
-1
votes
1
answer
155
views
Missing validation in Laravel in some cases when using Form Request
I have got a problem with Laravel.
I have created a custom Form Request - let's call it CustomFormRequest. It is authorized and have got rules as it should be.
In one of the classes I use this request ...
0
votes
4
answers
142
views
How to validate date in laravel/formrequest
I have this type of date:
"Date": "2024-09-06T06:58:19.326Z",
How should I validate it in my FormRequest in Laravel?
I've tried this:
'required|date_format:Y-m-d\TH:i:s.u\Z'
and ...
1
vote
0
answers
66
views
Laravel's form request validation via (extending the FormRequest class) method [duplicate]
I've implemented the form validation in Laravel by creating my own UserStoreRequest class, which extends the FormRequest class. I'm using Ajax. BTW, whenever the validation fails, Laravel ...
-1
votes
2
answers
149
views
Laravel Form Validation redirecting to web routes when it fails
I have a Laravel app (v10.30.1) this api routes block:
<?php
use App\Http\Controllers\EmployeeController;
use Illuminate\Support\Facades\Route;
Route::prefix('v1')->group(function () {
...
1
vote
2
answers
171
views
Laravel Custom Request Is not woring
So I was trying to use Laravel custom request, following the documentation:
api.php
Route::post('/register-user', [AuthController::class, 'register']);
AuthController.php
namespace App\Http\...
1
vote
2
answers
241
views
Custom validation always return true on form request laravel
I have custom validation for my form request. When users input the value and the value exists also field deleted_at is not null this validation should be working.
the problem is even when I input the ...
1
vote
0
answers
67
views
Custom validation on form request Laravel
I want make a validation for my products table where SKU field deleted_at is not null (yes i have softdeletes).
what i have done is make Custom Rules:
namespace App\Rules;
use Closure;
use Illuminate\...
0
votes
1
answer
161
views
Form tag with request of more 1000+ request not able get in controller in laravel
When I am requesting all parameters than it is giving me NULL
My Controller store function as:
public function store(Request $request)
{
dd($request->all());
}
My view file as:
@extends('main'...
0
votes
1
answer
655
views
How to validate 2 form request in the same controller in laravel
I am validating a credit card, for which I created two form requests:
php artisan make:request StoreAmexRequest
php artisan make:request StoreVisaRequest
How can I use them in the same controller?
...
0
votes
1
answer
70
views
How do I protect properties from certain users in a FormRequest?
I have several models in a Laravel/Backpack app where write access to certain properties is restricted to certain user roles.
Say I have a model Client with the properties
name
phone
active
viewCount
...
0
votes
0
answers
98
views
Laravel Validation: use single field to validate a set fields
I have two fields that FormRequest is expecting to receive as a set: image_id and image_path.
However I want to only return a single message using the field image_path when the FormRequest receives a ...
3
votes
1
answer
2k
views
Custom Validation Message in Laravel with custom attribute
I am creating a rule for my validation on my laravel app.
i wrote my rules below
public function rules()
{
return [
'title' => 'required|string',
'taxonomies' =&...
4
votes
1
answer
907
views
How to get error validation data in Custom Form Request
I have created a custom request form for login validation, It works fine if I put email and password field that's what I set for rules, email and password is required, but the problem is, I can't use ...
0
votes
1
answer
116
views
How to pair two arrays input validation in Laravel?
I have a form request with rules
return [
'brand_id' => ['required', 'integer'],
'color_id' => ['required', 'integer'],
'name' => ['required', 'max:255', 'string'],
'capital' =...
2
votes
0
answers
62
views
Laravel validation "Present" does not work
I have created a FormRequest for updating a BlogPost as UpdateBlogRequest.
I set thumbnail as a "present" for validation. but when this input is empty I get "The thumbnail field must be ...
2
votes
3
answers
594
views
laravel 9 form validation error has space between field name
There are space comes after every character of field name while displaying errors in blade template in laravel 9 as mentioned in uploaded image
my code is mentioned as below
CODE IN HTML IS :
<...
2
votes
1
answer
1k
views
Laravel - How to pass a custom array or custom request to a FormRequest?
I need to create a custom request on the fly and pass the request to the Form Request. The closest answer that I found was this SO answer. However when I run $request->validated(), it gives me ...
0
votes
1
answer
219
views
Laravel merge eloquent validation rule with a Rule::
How to merge eloquent validation rule with a Rule::
This is what I am attempting to run, but it chokes on the [ ] with Method Illuminate\Validation\Validator::validateRequired|email does not exist.
...
0
votes
1
answer
244
views
Laravel validation for row uniqueness
Working in Laravel 9, and I am doing my validations in FormRequests.
I have a email_updates table.
I have 3 columns, email, product_uuid, affiliate_uuid, and I am looking to enforce row uniqueness. An ...
-1
votes
3
answers
264
views
Multiple inputs in one validation rule
return [
'contract_code' => 'required',
'name' => 'required|string',
'abbreviation' => 'required|string',
'linecount_divisor' => 'required|integer'
];
// into input fields => '...
-1
votes
1
answer
114
views
Laravel FormRequest is modifying the input
I am having trouble using the Laravel Validator to validate some data. The validator is modifying properties of the input to null.
The data passed to be validated is a mix of array and objects (in ...
0
votes
0
answers
34
views
FormRequest messages() function does not translate all rules [duplicate]
I have no problem to get "required", "unique" or "email" rules translated. However, required_if and prohibited_if keep showing up in English.
File lang/es/validation.php ...
0
votes
1
answer
125
views
Laravel Validating An Array in Update Method unique filter
I am new to Laravel. I try to validate an array in Laravel 9.
for using a unique filter I have a problem.
at first, I try to use this way
$rules = [
'*.id' => 'integer|required',
'*.key' =&...
1
vote
2
answers
746
views
Laravel: Is it possible to apply different form validation rules to objects in an array
I have a Laravel 9 API.
I am posting the following json to an endpoint.
{
"shapes": [
{
"type": "Point",
"coordinates": [1, 2]
},
{
...
1
vote
1
answer
207
views
Laravel multiple fields validation not working
I'm trying to validate three input fields.
If the fields are null then the three fields are not mandatory, but If at least one of them is not empty (null) then all three should be mandatory. But It's ...
-1
votes
3
answers
892
views
Laravel how to validate two request inputs againt single column in form request
I am working with laravel 9.1. I want to validate two request inputs in single column of a table. below is my validation rule in form request.
Basically name = resource_name . permission_type i ...
2
votes
3
answers
4k
views
laravel Form request validation return 404 error
i'm new to laravel , hope someone could help me with this problem ,
i've created a request class to validate my inputs . But when the validation fails it doesn't return any error messages instead ...
0
votes
0
answers
187
views
Laravel different FormRequest conditioned by querystring
In some methods of a controller I would like to be able to use different FormRequest depending on a value in the querystring, for example:
// always using the same route, only qs change
// different ...
1
vote
2
answers
2k
views
How to get Laravel FormRequest errors in the controller?
I know i can get the errors in a view with @if ($errors->any()) or similars. But what if I want to get the validation errors in the Controller to return it as JSON?
RegisterRequest.php
<?php
...
0
votes
2
answers
2k
views
Laravel 9: FormRequest::withValidator method throwing error
I have a FormRequest with the withValidator() method (which I copied exactly as it is in the Laravel documentation), but when executing the class an error is returned.
Class:
<?php
namespace App\...
0
votes
1
answer
105
views
Laravel Predefined options in form request
I've created a FormRequest to validate some fields, and I would like that one of those fields only accept the options that a I give it
Searching I found something like this
"rule" => '...
0
votes
1
answer
80
views
Numeric|max Throws Bad Method Call Exception
I'm recieving the following error from the from request class in Laravel.
BadMethodCallException: Method Illuminate\Validation\Validator::validateNumeric|max does not exist.
in /var/www/html/vendor/...
1
vote
2
answers
372
views
Laravel Auth FormRequest works when accepting JSON, fails when accepting form data
This is very strange. I have an endpoint that accepts a PUT request.
namespace App\Http\Requests;
use Dingo\Api\Http\FormRequest;
class UpdateTestRequest extends FormRequest
{
public function ...
1
vote
1
answer
4k
views
The email has already been taken [duplicate]
I'm going to edit a row using form request validate laravel, but when editing if I do not change the email, The email has already been taken error. Gives
this is from request validate EditAdmin
<?...
0
votes
1
answer
940
views
How to deal with Image using validated method - Form Request (Laravel 9)
My form has 4 fields name, email, website and image
When only name, email, website fields are passed the following code saves the data perfectly to my DataBase.
public function store(...
0
votes
0
answers
75
views
Laravel - Drop down value is not updating to database
I was trying to update the dropdown value from user input to database here is my code-
my drop down input field in the user from -
<div class="form-group">
{{Form::label('...
-1
votes
1
answer
754
views
Why we retrieve the validated input data when using form request?
I'm using Laravel 8, and in the Laravel document, I see this line of code for retrieving the validated input data then using form requests.
// Retrieve the validated input data...
$validated = $...
0
votes
2
answers
1k
views
Laravel: make validation rule fail when using closure
Say I have a custom logic for validating the uniqueness of a FormRequest field, something requiring to find another resource in the database like below:
class CreateMyResourceRequest extends ...
1
vote
1
answer
1k
views
Laravel unique validation for combined multiple fields by custom logic
I am currently using Laravel 9 for my project.
Here is my validation rules
public function rules()
{
$parent_id = $this->parent_id != 0 ? $this->parent_id : null;
return [
'name'...
1
vote
1
answer
2k
views
Laravel 9 custom FormRequest throws "Object of type Illuminate\Session\Store is not callable"
Im testing out the new laravel 9 and I sadly come across this surprise.
After using PHP artisan make:request UpdateUserRequest and setting this as my request class on the incoming update function, ...
0
votes
1
answer
625
views
Laravel: how to validate relationship when using a route resource identifier that differs from database identifier
I'm working with Laravel nested resources to serve a many-to-many relationship. I'm working on a Football app and I want to link Competitions with Seasons, e.g. Premier League with 2021/22 season.
...
2
votes
1
answer
1k
views
¿How to create a custom FormRequest from normal Request?
I find something lost...
The problem
I need to construct 2 custom FormRequest from 1 normal Request
Let's suppose this fake scenario
First FormRequest
StoreClientRequest
Second FormRequest
...
1
vote
3
answers
2k
views
Laravel custom form request redirecting to index page
I've created a custom form request with php aritisan make:request, I have added in validation rules:
public function rules()
{
return [
'first_name' => 'required|string',...
5
votes
1
answer
4k
views
Laravel 8.65 validation error messages and old values not showing in Blade files
I am using FormRequest to validate data. I know this question was asked many times, and the community tried to solve this issue in many ways, but none of them solved my problem. Reference links are ...
0
votes
1
answer
259
views
L8 - Make a FormRequest from another FormRequest fails
I've a simple code (more o less) like this.
Routes:
Route::post('car', 'CarController@store')->name('insert_car.store');
Route::post('car-italian', 'CarItalianController@store')->name('...
0
votes
1
answer
123
views
L8 - API - Form Request on optional input JSON object
I'm working on Form Request and I've a question about how to use it with optional input object.
My API get a simple input JSON like:
{
"user": [
{
"name": &...
0
votes
0
answers
1k
views
How to validate array of objects in laravel?
I have an array of objects with different, dynamic parameters. And I'm trying to find a way to validate it based on the object type value.
Is there any way to make it with the FormRequest?
[
{
...
0
votes
2
answers
1k
views
How to check for resource existence before validation in Laravel with FormRequests
I've looked around but I haven't been able to find a way to perform an existence check of a resource before validating an incoming request with Laravel 8 FormRequest classes.
Basically, I want to ...
0
votes
4
answers
1k
views
How to validate email as unique while updating data using laravel form request?
I'm using form request to validate data into update method. I'm trying to validate email as a unique value expect requested user email like this
public function rules() {
$user = $this->user();...