Hello, in this code below I make a delete in the database of the selected records in a list of chekboxes.
I have an array of Ids that is mounted as follows:
Array (
[0] => 810
[1] => 811
)
On top of this array I make a foreach search each record and call the delete method, complete code below:
public function destroy_download($id = 0){
$ids = ($id >= 1) ? array($id) : Input::get('ids');
if( ! empty($ids) ){
foreach ($ids as $id) {
$download = Download::find($id);
$download->delete();
}
}
}
This should work correctly, however it gives the following error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to a member function delete() on a non-object
on line:
$download->delete();
It's as if the record has not been found.
It removes the record in the database only that happens this error, can anyone imagine what it is?
The Array is correct, I've debugged but it always does.