I want to write custom from validation , but when I’m using custom validation in my store controller it gets me error the error is : InvalidArgumentException: Database connection [vendor] not configured. in file D:clodth_projectcloth_apivendorlaravelframeworksrcIlluminateDatabaseDatabaseManager.php on line 152 my validation class is : class StoreRequest extends FormRequest { /** * Determine if the user is ..
Category : validation
I have three nullable fields ( Coupon, Membership, Offer) which are to be filled from requests. I want to validate/restrict users so that they can only fill one of these fields. As the fields are not required, I cannot use the required:* validators to handle this. I know this can be handled in the front-end, ..
i’ new to laravel here i’m create registration API, i set private function for validation but not show validation. that is my validation function `private function validateInfo($request, $toValidate) { $validator = Validator::make($request->all(), $toValidate); if ($validator->fails()) { $errors = $validator->errors()->toArray(); $values = array_values($errors); $arr = []; foreach ($values as $errorlst) array_push($arr, $errorlst[0]); $error = implode(‘,’, $arr); ..
I need help to set a minimum age for the user to be over 18 years. This is the user’s controller $request->validate([ ‘first_name’ => ‘required|max:255’, ‘last_name’ => ‘required|max:255’, ‘status’ => ‘required|max:50’, ‘phone’ => ‘required’,’unique:users’,’min:10′,’numeric’, ‘date_of_birth’ =>’required|date’, ‘address’ => ‘required|max:255’, ‘country’ => ‘required’, ‘role_id’ => ‘required|max:11′, ’email’ =>[ ‘required’, ’email’, ‘max:255’, Rule::unique(‘users’)->ignore($row->id) ], profile blade <div ..
In profile.blade, while updating the inputs in the profile getting Error The phone has already been taken. Controller: public function profileUpdate(Request $request) { $user = Auth::user(); $messages = [ ‘user_name.required’ => __(‘The User name field is required.’), ‘last_name.required’ => __(‘The Last Name field is required.’), ‘first_name.required’ => __(‘The First Name field is required.’), ‘phone.required’ => ..
I want to set require validation for array of objects in laravel and used following rule: [ ‘translations.*.languageId’ => [‘required’, ‘numeric’, Rule::in(Language::all()->pluck(‘id’))], ‘translations.*.data.title’ => ‘required|string’, ] but there is problem when i send request without translations key the validate function does not throw require error for translation key. so i add translations key separately too. ..
Table : charges id | ac_id | year | | – | — |————– | | 1 | 1 | 2021 | | 2 | 1 | 2020 | | 3 | 2 | 2021 | | 4 | 2 | 2020 | I am having a problem while doing validation, the year should be ..
I have a multi select form that returns 1, 2 and 3. I wanted to make a validation that it will only accept certain combinations such as 1 1 & 2 1 & 2 & 3 2 2 & 3 Any ideas how to make this work? Thank You! Sourc..
I have a multi select form that returns 1, 2 and 3. I wanted to make a validation that it will only accept certain combinations such as 1 1 & 2 1 & 2 & 3 2 2 & 3 Any ideas how to make this work? Thank You! My blade file <select id="role" class="form-multiselect ..
I have been using Laravel for a couple weeks now and I love the framework. However, with models is there any actual robust system? Creating models, like the user model, just seems to be string arrays of what you do and do not want modified in queries. The place I see validation of the models ..
I have Laravel 7 form with many inputs, need to retrieve the inputs while validating, this in the form blade “` <input type="text" value="{!! clean($translation->title) !!}" placeholder="{{__("Title")}}" name="title" class="form-control"> “` need to know how to use old in such case to retrieve the inputs. Thanks Sourc..
I’m building custom avatar functionality for my project. Users can select an image to upload. I made validation as follows: ‘avatar’ => ‘nullable|max:10000|image|mimes:png,jpeg,jpg’ It works for real file extensions like .docx and .xlsx. However, when i upload fake file extensions like .pnh and .yukelele, my validation weirdly succeeds. Does anyone have a fix? Sourc..
I would like to create a validation rule which checks if the combination of two values is unique. There is a field for the street (id) and the house number. Both fields are required. Further, no new entry should be created if a certain combination of street and house number already exists. How can I ..
{ "name" : "parent_node", "children: [ { "name" : "child-1", "children: [ { "name" : "subchild-1", //unlimited childrens } ] } ] } —————————————— $rules = ([ ‘name’ => ‘required|string’, ‘children.*.name’ => ‘required|string’ ]); I want to check validation dynamically on dynamic nested array Instead of using ‘children.*.name Validation should check nested array itself because ..
I’m sending have an array of JSON objects that I’m POSTing to the DB with other data: { "emotions":[ { "id":1, "intensity":67, "new_intensity":67 }, { "id":2, "intensity":67, "new_intensity":67 }, { "id":3, "intensity":64, "new_intensity":64 }, { "id":4, "intensity":64, "new_intensity":64 }, { "id":5, "intensity":64, "new_intensity":64 } ], "situation":"An event", } What I want to do is validate ..
I’m working on laravel Project i’m using custom messages when laravel validation fails when i try to store data. All messages working fine only password confirmed same error not showing any message Method: public function store(Request $request) { $validatedData = $request->validate( [ ‘name’ => ‘required’, ‘username’ => ‘required|unique:users’, ‘age’ => ‘required’, ‘sex’ => ‘required’, ‘organization_id’ ..
There is a model event. I wanna update it. The custom request is used for validation, but have several problems. Every event has two user’s relations – client and executor. As an example, I wanna change the event time. That time should be after now and should be free in the executor. The first validation ..
I’ve been struggling with something I would have expected to be a very simple task in Laravel. Basically, I have a table with multiple columns with default values, to allow user to leave certain fields empty instead of having to write "0" everywhere. This is how my migration looks for reference: public function up() { ..
I would need some help understanding what I am doing wrong. I have really basic ‘required’ fields defined in a PostUpdateRequest rules method. Then, my update method in PostController: public function update(PostUpdateRequest $request, Post $post) { $post->update($request->validated()); $post->tags()->sync(request(‘tags’)); return redirect() … } When I use the method without validation, it works: public function update(Request $request, ..
I’ve got the following code and it’s working just well as expected when uploading images but I noticed when I try to upload a video I get the error IlluminateHttpExceptionsPostTooLargeException. I was expecting to get an error on browser "The make field should be an image" just as the other validations are working. Could someone ..
I would like to validate multiple upload image in laravel using ajax, I use dynamic add/remove upload file. Maybe the problem in my validation controller, because json doesn’t response this is my controller : $rules =[ ‘img_thumbnail.*.file’ => [‘image’,’mimes:jpeg,png’,’max:5000′], ]; $message = [ ‘img_thumbnail.*file.required’ => ‘Image must fill’, ‘img_thumbnail.*file.image’ => ‘File Should Image’, ‘img_thumbnail.*file.mimes’ => ..
I want to do some validation for a field. Right now works for unique values, the problem is that on Update I get the same error. So I want to filter the request, if that post request contain ID field then this field shouldn’t be unique. public function rules() { return [ ‘customer_id’ => ‘required|unique:customers’, ..
I have a request to log all validation exceptions in my application. I have all of it working except for the request parameters is empty. I’m able to dd the request parameters and it displays but it doesn’t seem to log. How is the $data value getting wiped? In appExceptionsHandler.php: /** * Report or log ..
I am making a site where users can like books and also comment on them. I want the user to be able to comment only if it has liked at least 3 books. How can I implement this? What is this kind of validation called because I am having a hard time searching for solutions. ..
I have the following validation logic, but it does not work properly: public function getFeedback(Request $request) { $validator = Validator::make($request->all(), [ ‘id.*’ => ‘integer’, ‘job_id.*’ => ‘integer’, ‘quality_cycle_id.*’ => ‘integer’, ‘rating.*’ => ‘ineteger’, ]); if($validator->fails()) { return back()->withInput()->withErrors(json($validator->errors())); } } Sourc..