I want to do a delete by id with the Laravel ORM , and from what I have read it is not possible, and it must be done in a similar way to this.
File::find($code)->delete();
either
$file = File::find($code);
$file->delete();
in both cases it throws me an error Call to a member function delete() on null
The case is that I delete the record from the database.
Could someone tell me what I'm doing wrong or if I've missed something?
The error was that find() can only be used when we want to search for the primary_key, in my case I had to use:
You could try something like:
Tell us how it goes.
Did you try this?
You can try with this code