| @@ 239-246 (lines=8) @@ | ||
| 236 | public function delete($value, $attribute = 'id') |
|
| 237 | { |
|
| 238 | if ($attribute == 'id') { |
|
| 239 | \DB::transaction(function () use ($value) { |
|
| 240 | $model = $this->model->lockForUpdate()->find($value); |
|
| 241 | if (! $model) { |
|
| 242 | \ErrorHandler::notFound(class_basename($this->model).' with id : '.$value); |
|
| 243 | } |
|
| 244 | ||
| 245 | $model->delete(); |
|
| 246 | }); |
|
| 247 | } else { |
|
| 248 | \DB::transaction(function () use ($value, $attribute) { |
|
| 249 | $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) { |
|
| @@ 336-345 (lines=10) @@ | ||
| 333 | * @param integer $id |
|
| 334 | * @return void |
|
| 335 | */ |
|
| 336 | public function restore($id) |
|
| 337 | { |
|
| 338 | $model = $this->model->onlyTrashed()->find($id); |
|
| 339 | ||
| 340 | if (! $model) { |
|
| 341 | \ErrorHandler::notFound(class_basename($this->model).' with id : '.$id); |
|
| 342 | } |
|
| 343 | ||
| 344 | $model->restore(); |
|
| 345 | } |
|
| 346 | ||
| 347 | /** |
|
| 348 | * Fill the model with the given data. |
|