Hello all, I have innormal problem. My code (I'm using Slim):
$app->get('/delete/:id', function($id) use($app) {
$todo = Todo::find($id);
$todo->delete();
$app->redirect('');
});
And this throw
Fatal error: Call to a member function delete() on a non-object in
on $todo->delete();
, but it has been deleted. What I should do?
Does the todo with that $id exists, probably it seems like it's deleting it because it never existed.
Yeah, it exists. Before deleting I see that record.
Maybe just add
if ( ! $todo ) {
// No record found
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community