Reputation: 12598
I'm fairly new to Laravel, I have an MySQL database table that looks like this...
id | name | email
------------------------------
23 | john | [email protected]
77 | jane | [email protected]
I am trying to delete the row with the email address [email protected], I can select the row directly like this...
$deleteimage = Image::find(77);
$deleteimage ->delete();
But how can I select the row by the email address instead?
Upvotes: 1
Views: 56
Reputation: 91922
Eloquent comes with a full query builder, using the same syntax as the Laravel DB
query builder. So you can delete all the rows with a certain e-mail address like this:
Image::where('email', '[email protected]')->delete();
You can explore all the functions provided by the Eloquent query builder in the API documentation. There are lots of things in Laravel that is not documented in the normal manual.
Upvotes: 4