Support the ongoing development of Laravel.io →
posted 2 years ago
Validation
  • PHP 8.1.4
  • Apache/2.4.53
  • Laravel Framework 9.33.0

I am trying to add messages error in every validation variable, searching and find this withValidator

// AccountRequest.php
public function withValidator($validator)
{
    $validator->after(function ($validator) {
        if ($this->request->has('modal') && $validator->fails()) {
            $validator->errors()->add('modal', $this->request->get('modal'));
        }
    });
}

The problem is everytime this code $validator->fails() running, my local server got so slow, and crash, even thought the $request is just 2 data

What I have done so far is, changing the server from using php artisan serve to apache

This is error on apache log

[Sat Oct 29 21:02:42.135270 2022] [php:error] [pid 30872:tid 1896] [client 127.0.0.1:61836] PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

Thanks In Advance

Last updated by @verdymas 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Verdymas verdymas Joined 2 Nov 2022

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.