public function deleteSaved()
{
$exceptions = [];
while ($model = array_pop($this->saved)) {
try {
if (!$this->delete($model)) {
throw new DeleteFailedException(get_class($model));
}
} catch (Exception $e) {
$exceptions[] = $e;
}
}
// If we ran into any problems, throw the exception now
if ($exceptions) {
throw new DeletingFailedException($exceptions);
}
}
/** * Delete all the saved models. * * @throws \League\FactoryMuffin\Exceptions\DeletingFailedException * * @return void */ public function deleteSaved() { parent::deleteSaved(); try { $this->flush(); } catch (Exception $e) { throw new DeletingFailedException([$e]); } }