/**
  * Get the model event that triggered the snapshot.
  *
  * @return string
  */
 protected function getEvent()
 {
     if ($this->event == 'deleted' && $this->modelSoftDeletes()) {
         return 'soft-deleted';
     }
     if ($this->event == 'updated' && $this->modelSoftDeletes() && $this->model->{$this->model->getDeletedAtColumn()}) {
         return 'restored';
     }
     return $this->event;
 }
 public function __construct(Model $model)
 {
     $this->model = $model;
     if (method_exists($model, 'trashed')) {
         $this->isSoftDelete = true;
         $this->deletedAtColumn = $this->model->getDeletedAtColumn();
     }
     $this->criteria = new Collection();
     $this->boot();
     $this->scopeReset();
 }
Example #3
0
 /**
  * Restore the soft-deleted model instances.
  *
  * @return int
  */
 public function restore()
 {
     if ($this->model->isSoftDeleting()) {
         $column = $this->model->getDeletedAtColumn();
         return $this->update(array($column => null));
     }
 }