15
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LaravelでDBのレコードを削除する4つの方法

Posted at

どれもOKでした!

whereで絞り込んで、delete()で削除

new して削除

$db_data = new Product;
$db_data->where('id', 1)->delete();

new しないで削除

Product::where('id', 1)->delete();

idで一意に絞り込んで、destroy()で削除

new して削除

$db_data = new Product;
$db_data->destroy(1);

new しないで削除

Product::destroy(1);
15
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?