jeudi 1 juillet 2021

Laravel update function data not passing to DB but no error

Hey guys we are new to Laravel and Stack(hope this is a clear question) and recently made a post trying an update method with ajax and js but returned many problems, and since returned to a basic Laravel function. For some reason we can't quite understand why this function is not returning any data, there aren't any errors since we had parsed through them all.. sql contraints, null data, symphony handler etc etc.. as well as obviously reading other similar stack questions but with no resolution. We have tried to change the controller function, the method calls (PUT PATCH POST) Does anybody have any suggestions what is going wrong here? I'm sure its really obvious.. thank you!

Quindi.. User clicks edit post, makes edit, confirm.. page refreshes with no changes, no error and no data in database.

 <form id="form-edit-post" action="/posts//update" method="POST" data-parsley-validate>
                        
                        
 Route::patch('/posts/{id}/update', [PostsController::class, 'update'])->name('post.update');
    public function update(Request $request, Post $post)
    {       

        $this->validate($request, array(
            'content' => 'required',
            'location' => 'required',
        ));

        $post->user_id = Auth::user()->id;
        $post->content = $request['content'];
        $post->location = $request['location'];
        $post->update();

        return back()->with('success','Post Updated Successfully');
        
    }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3dymZyI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire