“Hapus metode Laravel” Kode Jawaban

Laravel Form Metode Hapus

// Blade
@method('delete')

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

hapus laravel

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

Hapus metode 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 membuat atau memperbarui

// 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

Hapus laravel

Flight::destroy(1);

Flight::destroy(1, 2, 3);

Flight::destroy([1, 2, 3]);

Flight::destroy(collect([1, 2, 3]));
Magnificent Mink

Laravel menghancurkan atau menghapus

<form action="blog/{{$blog->id}}" method="post"> 
         @csrf 
         @method("DELETE")         
         <input type="submit" value="Delete" />
      </form>
Irfan

Jawaban yang mirip dengan “Hapus metode Laravel”

Pertanyaan yang mirip dengan “Hapus metode Laravel”

Lebih banyak jawaban terkait untuk “Hapus metode Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya