| @@ 440-447 (lines=8) @@ | ||
| 437 | public function delete($value, $attribute = 'id') |
|
| 438 | { |
|
| 439 | if ($attribute == 'id') { |
|
| 440 | \DB::transaction(function () use ($value) { |
|
| 441 | $model = $this->model->lockForUpdate()->find($value); |
|
| 442 | if (! $model) { |
|
| 443 | \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
|
| 444 | } |
|
| 445 | ||
| 446 | $model->delete(); |
|
| 447 | }); |
|
| 448 | } else { |
|
| 449 | \DB::transaction(function () use ($value, $attribute) { |
|
| 450 | $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) { |
|
| @@ 537-546 (lines=10) @@ | ||
| 534 | * @param integer $id |
|
| 535 | * @return void |
|
| 536 | */ |
|
| 537 | public function restore($id) |
|
| 538 | { |
|
| 539 | $model = $this->model->onlyTrashed()->find($id); |
|
| 540 | ||
| 541 | if (! $model) { |
|
| 542 | \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
|
| 543 | } |
|
| 544 | ||
| 545 | $model->restore(); |
|
| 546 | } |
|
| 547 | ||
| 548 | /** |
|
| 549 | * Build the conditions recursively for the retrieving methods. |
|