samedi 23 juin 2018

laravel 5.6 destroy function

the issue is when I try to press the button which it should direct me to destroy function in my controller, somehow it direct me the show function

I used method = delete and the route = posts.destroy

                  <tbody>
                          @foreach($MyPosts as $post)
                          <tr>
                            <th scope="row">1</th>
                            <td></td>
                            <td></td>
                            <form method="delete" action=""> 
                            <td> <input class="btn btn-danger"  value="DELETE" type="submit" style="width:100px"></td>
                            </form>
                            @csrf
                            <td><a href=""><input type="submit" class="btn btn-warning" value="edit"></a> </td>
                          </tr>
                          @endforeach
                       </tbody>

the route file

   Route::get('/Testing', 'ViewsController@getTest');
   Route::get('/contact', 'ViewsController@getcontact');
   Route::get('/about', 'ViewsController@getabout');
   Route::get('/', 'ViewsController@getIndex');
   Route::resource('/posts','PostController');


  public function show($id)
{
        $post = Post::find($id);
        dd($post);
        return view('posts.show')->with('posts',$post);
}


public function destroy($id)
{   
    return('destroy');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire