Search
 
SCRIPT & CODE EXAMPLE
 

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');
});
Comment

laravel delete method

public function destroy(Post $post)
    {
        Gate::authorize('delete',$post);

        Storage::delete("public/cover/".$post->cover);
        $post->delete();

        return redirect()->route('index')->with('status','Post Deleted');
    }
Comment

PREVIOUS NEXT
Code Example
Php :: malformed utf-8 characters possibly incorrectly encoded php 
Php :: sort multidimensional array php by key 
Php :: explode in laravel blade 
Php :: php create zip from folder 
Php :: php mysqli connect err0r 
Php :: remove index.php in codeigniter 
Php :: query-data-from mysql and php 
Php :: how to show validation error in laravel 8 
Php :: php case switch 
Php :: how to redirect to another page from laravel blade 
Php :: save array in mysql php 
Php :: woocommerce order get_data() 
Php :: php syntax 
Php :: random word using a wordlist php 
Php :: php array longest string 
Php :: laravel make model with migration 
Php :: laravel conditional class 
Php :: array_key_exists vs in_array 
Php :: laravel migration change column default 
Php :: convert multi-dimensional array into a single array in laravel 
Php :: php convert string to url 
Php :: php setinterval 
Php :: laravel count group by date 
Php :: php counter 
Php :: wordpress featured image show 
Php :: array reduce associative array php 
Php :: laravel auth user_id 
Php :: woo set_stock_quantity 
Php :: php eliminar elementos vacios array 
Php :: continue not in the loop or switch 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =