League\FactoryMuffin\Stores\AbstractStore::deleteSaved PHP Method

deleteSaved() public method

Delete all the saved models.
public deleteSaved ( ) : void
return void
    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);
        }
    }

Usage Example

Example #1
0
 /**
  * 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]);
     }
 }