jeudi 3 septembre 2020

Delete not working and redirecting to the same page - Laravel

I am new to laravel and was facing a problem. I have made a delete function in Controller and added it in the route properly. Then I connected it to a button in the view. When I press the button, it redirects me to the same page without deleting anything.

Here's my function :

 public function delete_user($id){
        $data = User::where('id' , $id);
        $data->delete();
        return route('home');
    }

Here's my route :

Route::get('/delete/user/{id}' , 'UserController@delete_user');

I am adding it in view like this :

 <a href=""><button class="btn btn-info btn-fill pull-right">Delete Profile</button></a>
                           

After redirecting there is a ? infront of the url like abcd.com/delete/1?

When I hover over the button, it shows the correct route(bottom left corner in image), but nothing is happening when I press it : enter image description here

Any help would be appreciated. Thanks

EDIT : The same function works perfectly fine in another view instance.



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

Aucun commentaire:

Enregistrer un commentaire