Level 7
Try this:
Picture::where('filename', $filename)->delete();
If you have the model already in a variable, then:
$picture->delete();
3 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi .. i am trying to delete a record, but not through the primary key.. Im doing the following ;
$picture=Picture::where("filename","=",$filename);
$picture->delete;
The record is never deleted, my assumption is that laravel will only allow the delete if I use a key instead of a normal column... What am I missing? thanks in advance #newbie
Try this:
Picture::where('filename', $filename)->delete();
If you have the model already in a variable, then:
$picture->delete();
Please or to participate in this conversation.