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

gme's avatar
Level 1

500 Internet Server Error after Form submitting

Hello,

i started the laracast tutorial laravel 5.4 from scratch. Now i'm in session 12 and have my first bug. I try a lot, but i can't fix it.

Here are the relevant files

web.php https://pastebin.com/DFbg7AeZ

PostController.php https://pastebin.com/HawSTz4J

create.blate.php https://pastebin.com/VrtMaYCS

Post.php https://pastebin.com/QyDaBa1e

Model.php https://pastebin.com/qhqMbeL8

I hope someone can help me, laravel don't give me an error.

Best regards GME

0 likes
6 replies
vipin93's avatar

did u using ajax if yes then use chrome dev tools network->response and make your Post model fillable" ['title', 'body']"

gme's avatar
Level 1

no, i dont use ajax :(

gme's avatar
Level 1

yes, but i get a 500 server error, there is no error message and no entry in the log files

gme's avatar
Level 1

i have found the bug and fix it...

PostController.php

replace:

$this->validate(request, [ 'title' => 'required', 'body'=> 'required' ]);

with:

$this->validate(request(), [ 'title' => 'required', 'body'=> 'required' ]);

Snapey's avatar

You get that error because you don't pass the request into your store method. You can use the request() helper as you have done, but most would pass the request to the method;

    public function store(Request $request)
    {
            $this->validate($request, [
                'title' => 'required',
                'body'=> 'required'
            ]);
            Post::create($request->only(['title', 'body']));
            return redirect('/');          
       
    }

Please or to participate in this conversation.