“Méthode Laravel Delete” Réponses codées

Méthode du formulaire Laravel Supprimer

// Blade
@method('delete')

// Html
<input type="hidden" name="_method" value="delete">
TheDutchScorpion

Force Delete Soft Delete Laravel

Soft Delete : $user->delete();
Force Delete : $user->forceDelete();
Restore Soft Deleted Item : $user->restore();
Lokesh003Coding

Laravel Supprimer

DB::table('users')->where('votes', '>', 100)->delete();
unmeego

Supprimer la méthode 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');
});
Smoggy Stag

Laravel Créer ou mettre à jour

// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Models\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99, 'discounted' => 1]
);
Embarrassed Eel

Méthode Laravel Delete

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

Réponses similaires à “Méthode Laravel Delete”

Questions similaires à “Méthode Laravel Delete”

Plus de réponses similaires à “Méthode Laravel Delete” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code