|
@@ 408-428 (lines=21) @@
|
| 405 |
|
* |
| 406 |
|
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
| 407 |
|
*/ |
| 408 |
|
public function deleteDelete(ModelConfigurationInterface $model, Request $request, $id) |
| 409 |
|
{ |
| 410 |
|
$item = $model->getRepository()->find($id); |
| 411 |
|
|
| 412 |
|
if (is_null($item) || ! $model->isDeletable($item)) { |
| 413 |
|
abort(404); |
| 414 |
|
} |
| 415 |
|
|
| 416 |
|
$model->fireDelete($id); |
| 417 |
|
|
| 418 |
|
if ($model->fireEvent('deleting', true, $item) === false) { |
| 419 |
|
return redirect()->back(); |
| 420 |
|
} |
| 421 |
|
|
| 422 |
|
$model->getRepository()->delete($id); |
| 423 |
|
|
| 424 |
|
$model->fireEvent('deleted', false, $item); |
| 425 |
|
|
| 426 |
|
return redirect($request->input('_redirectBack', back()->getTargetUrl())) |
| 427 |
|
->with('success_message', $model->getMessageOnDelete()); |
| 428 |
|
} |
| 429 |
|
|
| 430 |
|
/** |
| 431 |
|
* @param ModelConfigurationInterface $model |
|
@@ 439-463 (lines=25) @@
|
| 436 |
|
* |
| 437 |
|
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
| 438 |
|
*/ |
| 439 |
|
public function deleteDestroy(ModelConfigurationInterface $model, Request $request, $id) |
| 440 |
|
{ |
| 441 |
|
if (! $model->isRestorableModel()) { |
| 442 |
|
abort(404); |
| 443 |
|
} |
| 444 |
|
|
| 445 |
|
$item = $model->getRepository()->findOnlyTrashed($id); |
| 446 |
|
|
| 447 |
|
if (is_null($item) || ! $model->isRestorable($item)) { |
| 448 |
|
abort(404); |
| 449 |
|
} |
| 450 |
|
|
| 451 |
|
$model->fireDestroy($id); |
| 452 |
|
|
| 453 |
|
if ($model->fireEvent('destroying', true, $item) === false) { |
| 454 |
|
return redirect()->back(); |
| 455 |
|
} |
| 456 |
|
|
| 457 |
|
$model->getRepository()->forceDelete($id); |
| 458 |
|
|
| 459 |
|
$model->fireEvent('destroyed', false, $item); |
| 460 |
|
|
| 461 |
|
return redirect($request->input('_redirectBack', back()->getTargetUrl())) |
| 462 |
|
->with('success_message', $model->getMessageOnDestroy()); |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
/** |
| 466 |
|
* @param ModelConfigurationInterface|ModelConfiguration $model |
|
@@ 474-498 (lines=25) @@
|
| 471 |
|
* |
| 472 |
|
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException |
| 473 |
|
*/ |
| 474 |
|
public function postRestore(ModelConfigurationInterface $model, Request $request, $id) |
| 475 |
|
{ |
| 476 |
|
if (! $model->isRestorableModel()) { |
| 477 |
|
abort(404); |
| 478 |
|
} |
| 479 |
|
|
| 480 |
|
$item = $model->getRepository()->findOnlyTrashed($id); |
| 481 |
|
|
| 482 |
|
if (is_null($item) || ! $model->isRestorable($item)) { |
| 483 |
|
abort(404); |
| 484 |
|
} |
| 485 |
|
|
| 486 |
|
$model->fireRestore($id); |
| 487 |
|
|
| 488 |
|
if ($model->fireEvent('restoring', true, $item) === false) { |
| 489 |
|
return redirect()->back(); |
| 490 |
|
} |
| 491 |
|
|
| 492 |
|
$model->getRepository()->restore($id); |
| 493 |
|
|
| 494 |
|
$model->fireEvent('restored', false, $item); |
| 495 |
|
|
| 496 |
|
return redirect($request->input('_redirectBack', back()->getTargetUrl())) |
| 497 |
|
->with('success_message', $model->getMessageOnRestore()); |
| 498 |
|
} |
| 499 |
|
|
| 500 |
|
/** |
| 501 |
|
* @param ModelConfigurationInterface $model |