laravel delete

94

php artisan make:model Flight
use App\Models\Flight;

$flight = Flight::find(1);

$flight->delete();
// 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]
);
Schema::table('flights', function (Blueprint $table) {
    $table->softDeletes();
});
Flight::destroy(1);

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

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

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

Comments

Submit
0 Comments