PHP Трейт Mpociot\Reanimate\ReanimateModels

Automagically manages soft-delete restores. All you need to do is use this trait inside your controller and (optionally) set the model to use for restoring When deleting the model append a new flash message to your redirect using the undoFlash method.
Показать файл Открыть проект

Открытые методы

Метод Описание
restoreModel ( $primary_key, $obj, $customIndexRoute = "" ) : Illuminate\Http\RedirectResponse Undo delete a model with a given primary key
undoDelete ( $primary_key ) : Illuminate\Http\RedirectResponse This is a ready-to-use route to restore models

Защищенные методы

Метод Описание
undoFlash ( Eloquent $model, string $customUndoRoute = "" ) : array Returns the undo flash data to append to your delete redirects

Приватные методы

Метод Описание
getUndoModel ( ) : Eloquent Returns the Model for the undo operation If it doesn't exist it tries to generate the class name by using the calling class name stripping of "Controller" and applying str_singular So a "CategoriesController" would look for a model called "Category"

Описание методов

restoreModel() публичный метод

Undo delete a model with a given primary key
public restoreModel ( $primary_key, $obj, $customIndexRoute = "" ) : Illuminate\Http\RedirectResponse
$primary_key int
$obj
Результат Illuminate\Http\RedirectResponse

undoDelete() публичный метод

This is a ready-to-use route to restore models
public undoDelete ( $primary_key ) : Illuminate\Http\RedirectResponse
$primary_key
Результат Illuminate\Http\RedirectResponse

undoFlash() защищенный метод

Returns the undo flash data to append to your delete redirects
protected undoFlash ( Eloquent $model, string $customUndoRoute = "" ) : array
$model Eloquent the deleted model
$customUndoRoute string
Результат array