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.
Afficher le fichier Open project: mpociot/reanimate

Méthodes publiques

Méthode 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

Méthodes protégées

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

Private Methods

Méthode 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 méthode

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

undoDelete() public méthode

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

undoFlash() protected méthode

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
Résultat array