@@ 623-640 (lines=18) @@ | ||
620 | * @param $id |
|
621 | * @return mixed |
|
622 | */ |
|
623 | public function update($id, array $attributes) |
|
624 | { |
|
625 | $this->applyScope(); |
|
626 | $_skipPresenter = $this->skipPresenter; |
|
627 | ||
628 | $this->skipPresenter(true); |
|
629 | ||
630 | $model = $this->model->findOrFail($id); |
|
631 | $model->fill($attributes); |
|
632 | $model->save(); |
|
633 | ||
634 | $this->skipPresenter($_skipPresenter); |
|
635 | $this->resetModel(); |
|
636 | ||
637 | event(new RepositoryEntityUpdated($this, $model)); |
|
638 | ||
639 | return $this->parserResult($model); |
|
640 | } |
|
641 | ||
642 | /** |
|
643 | * Delete a entity in repository by id. |
|
@@ 648-666 (lines=19) @@ | ||
645 | * @param $id |
|
646 | * @return int |
|
647 | */ |
|
648 | public function delete($id) |
|
649 | { |
|
650 | $this->applyScope(); |
|
651 | ||
652 | $_skipPresenter = $this->skipPresenter; |
|
653 | $this->skipPresenter(true); |
|
654 | ||
655 | $model = $this->find($id); |
|
656 | $originalModel = clone $model; |
|
657 | ||
658 | $this->skipPresenter($_skipPresenter); |
|
659 | $this->resetModel(); |
|
660 | ||
661 | $deleted = $model->delete(); |
|
662 | ||
663 | event(new RepositoryEntityDeleted($this, $originalModel)); |
|
664 | ||
665 | return $this->parserResult($model); |
|
666 | } |
|
667 | ||
668 | /** |
|
669 | * Delete a entity in repository by id. |