atton53's avatar

Not getting form data on laravel $request object sent from Vue Component ( VILT Stack )

Here is the quick explanation of the issue i am facing - (58 sec only)

https://komododecks.com/recordings/VKLRr4GiITxAi0XZfqvF


I can edit my posts, i can send existing post images ids to laravel controller to delete them, however - i am unable to send new images to the laravel controller.

Whenever i am adding new image on edit post, i am getting in empty array. ( please check the video abobe - only 58 seconds long )

This is my edit.vue file

This is my controller method


    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, string $uuid)
    {
        $validatedData  = $request->all();
        dd($validatedData);
        
        $post = Post::where('uuid', $uuid);
        $dataToUpdate = [
            'post_body' => $validatedData['post_body'],
            'excerpt' => Str::limit($validatedData['post_body'], 250, '....'),
        ];
        $post->update($dataToUpdate);

        // Uploading New Images
        if($request->hasFile('post_images')){
            $images = $request->file('post_images');
            foreach ($images as $image){
                $post->addMedia($image)->toMediaCollection(MediaCollection::PostImage);
            }
        }
        return redirect()->route('posts.show', $uuid);
    }

I am also getting this error message -

xhr.js:195 
        
        
       PUT http://127.0.0.1:8000/posts/f7a9938e-e138-44c5-bf80-1804351a7fc2 500 (Internal Server Error)

Please help me on it.

Thanks in advance. Talha

0 likes
7 replies
atton53's avatar

Hey @s4muel , Thanks for responding.

I got the same problem......with applying the above chnage..

however my create post is working well following the same method. Here is my create post component vue code

tisuchi's avatar

@atton53 Have you checked in your laravel.log file to get details about the error?

1 like
tisuchi's avatar

@atton53 It's hard for me to debug from here!

Here is the process you can follow.

  1. Try to upload a photo in the UI where you are supposed to get a 500 error in the console (as you have shown in the video)
  2. Then check the last entry of the laravel.log . This command may help you to get it.
tail -n 100 laravel.log

You may need to adjust your file path if you are in a different directory.

  1. You may see specific error details there starting with [XXXX-XX-XX XX:XX:XX] local.ERROR:

For example:

1 like
atton53's avatar

Hey @tisuchi

Interestingly, I can't see any 500 Internal Server Error in my Laravel log.

I guess the problem is in my Vue file.

tisuchi's avatar

@atton53 No, that's not what I mean.

I saw in your cast that there a 500 errors (which is an internal server error and should be written in the laravel.log file)

500 Internal Server Error

Correct, you won't get 500 Internal Server Error but you will get log why exactly you get this 500 internal server error

Please or to participate in this conversation.