Reputation: 383
I want to delete the associated file of a record after deleting the record. But I get $this->data empty in after delete callback method.
Upvotes: 2
Views: 695
Reputation: 43
It is actually not empty. It's just a mistake in the docs I think. Try this:
// perhaps after deleting a record from the database, you also want to delete
// an associated file
public function afterDelete() {
$file = new File($this->info['SomeModel']['file_path']);
$file->delete();
}
Upvotes: 0
Reputation: 804
I agree, but the docs are little bit unclear:
// perhaps after deleting a record from the database, you also want to delete
// an associated file
public function afterDelete() {
$file = new File($this->data['SomeModel']['file_path']);
$file->delete();
}
Upvotes: 1
Reputation: 126
you have to store the file name in variable before delete operation.
Upvotes: 2