Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hasanhatem's avatar

how to solve 409 Conflict in Validator with laravel 7

Hi, devs. I am having a problem in SEO (Ahrefs Site Audit) with Laravel Validator in Contact Page when I am returning errors via

        $validator = Validator::make($request->all(), [
            'name' => ['required', 'string', 'max:190'],
            'email' => ['required', 'email', 'max:190'],
            'subject' => ['required', 'string', 'max:190'],
            'message' => ['required', 'string', 'max:2000']
        ]);

        if ($validator->fails()) {
            return response()->json([
                'status' => false,
                'errors' => $validator->errors()
            ], 200);
        }

in Ahrefs site tell me I have this problem in Contact Page:

HTTP status code	409 Conflict

And The content type of this page:

text/html; charset=iso-8859-1

And the site classifies the problem as (Page has links to broken page)

But as you can see in the previous code, I returned the HTTP status (200) with an error message.

And in my contact page, there are no errors or warnings in (console)

This is the link to the page if you need it: https://blog.error-sd.com/contact

0 likes
5 replies
bugsysha's avatar

Just ignore it if you can't reproduce it. Who knows how it is testing your page.

hasanhatem's avatar

is there any official solution? how can make the page return 200 HTTP status? and why the page return 409 and I make it returned 200?

bugsysha's avatar

It can return 409 if you try to create model with an existing id.

hasanhatem's avatar

this is my send function in ContactController.php

public function send(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'name' => ['required', 'string', 'max:190'],
            'email' => ['required', 'email', 'max:190'],
            'subject' => ['required', 'string', 'max:190'],
            'message' => ['required', 'string', 'max:2000']
        ]);

        if ($validator->fails()) {
            return response()->json([
                'status' => false,
                'errors' => $validator->errors()
            ], 200);
        }

        $data = [
            'name'    => $request->name,
            'email'   => $request->email,
            'subject' => $request->subject,
            'message' => $request->message
        ];

        if (Contact::create($data)) {

            // Send the email
            Mail::send('emails.contact', [
                'name'    => $request->name,
                'email'   => $request->email,
                'subject' => $request->subject,
                'msg' => $request->message
            ], function ($mail) use ($data) {
                $mail->from($data['email']);
                $mail->to('here my email')->subject($data['subject'] . ' || From Blog');
            });

            return response()->json([
                'status' => true
            ]);
        }
    }
chcrtech's avatar

If your client has cookies turned off in their browser, we discovered this can return an unexpected 409 error.

Please or to participate in this conversation.