PHP Trait 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.
Datei anzeigen Open project: mpociot/reanimate

Public Methods

Method Description
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

Protected Methods

Method Description
undoFlash ( Eloquent $model, string $customUndoRoute = "" ) : array Returns the undo flash data to append to your delete redirects

Private Methods

Method Description
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"

Method Details

restoreModel() public method

Undo delete a model with a given primary key
public restoreModel ( $primary_key, $obj, $customIndexRoute = "" ) : Illuminate\Http\RedirectResponse
$primary_key int
$obj
return Illuminate\Http\RedirectResponse

undoDelete() public method

This is a ready-to-use route to restore models
public undoDelete ( $primary_key ) : Illuminate\Http\RedirectResponse
$primary_key
return Illuminate\Http\RedirectResponse

undoFlash() protected method

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
return array