Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

delete method laravel

//go to 18 min mark in link

//html:

<div class="btnContainer">
<form method="POST" action='/user/{{ $user->id }}'>
    @csrf
    @method('DELETE')
        <button type="submit" class="submitbtn" name="deleteUser">Delete user</button>
</form>
</div>

//Route: 

Route::delete('/user/{user}', function($id){
    $user = User::findOrFail($id);
    $user->delete();
    return redirect('/users');
});
Source by laracasts.com #
 
PREVIOUS NEXT
Tagged: #delete #method #laravel
ADD COMMENT
Topic
Name
8+2 =