Download the PHP package mpociot/reanimate without Composer

On this page you can find all versions of the php package mpociot/reanimate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package reanimate

Reanimate

Restoring models in laravel is easy. Simply call restore on the soft-deleted model and you're good to go. But what if you want to implement a simple undo mechanism in your application?

You need to take care of restoring the model, redirecting back, showing a success/error message...

Wouldn't it be nice if this process could be simplified?

Reanimate is a laravel package that allows you to do just that. It simplifies undoing of soft-deletes for your application.

Installation

Reanimate can be installed via composer, the details are on packagist, here.

To download and use this package, add the following to the require section of your projects composer.json file:

Run composer update to download the package

That's it. Take a look at the implementation guide, to get started.

Docs

What Reanimate does

A simplified deletemethod on your controller might look like this:

So how would you undo that delete call? You need to create a route, pass that object id, resolve the object, restore it if it exists and finally redirect back.

With Reanimate, this becomes:

undoFlash passes an array to your session with the following data:

So if your session has an undo array, you know that you should present your users a possibility to undo the deletion.

Just make sure that the undo route, points to the undoDelete method, available through the Reanimate Trait.

This method will then restore the model with the given ID and will redirect the user to a given index route.

Implementation & configuration

Every controller in your application, that currently takes care of deleting a model and now should benefit from Reanimate, needs to use the ReanimateModels Traits.

For example

Deletes

When you redirect your users after a successful delete call, simply append the ->with( $this->undoFlash( $deletedModel ) ); data to your redirect.

undoFlash will automatically do two things for you:

Auto generate an undo route:

When no custom undo route is specified, Reanimate generates a named route by using the model name + "Undo".

Example model names and undo routes:

User -> userUndo

Category -> categoryUndo

FileEntry -> fileEntryUndo

Auto generate an undo language key:

By default, a lang key can be used within your views, for the undo action. This key is a lowercase representation of your model name + .undo.message

Example model names and lang keys:

User -> user.undo.message

Category -> category.undo.message

FileEntry -> fileentry.undo.message

Restores

The easiest way to restore your models, is to add a named route to your routes.php that matches the generated undo route name.

This route needs to point to the undoDelete method of your controller.

This method takes care of restoring the model with the given primary key and returns a redirect to an auto generated index route.

Auto generated model name:

Since this method only receives the ID of your model, but not the model itself, Reanimate tries to guess the correct model name for you.

It's done by using the singular version of your Controller's name.

Example controller names and the matching model names:

UserController -> User

CategoriesController -> Category

FileEntryController -> FileEntry

Auto generated index route:

When no custom index route is specified, Reanimate generates a named route by using the model name + "Index".

Example model names and undo routes:

User -> userIndex

Category -> categoryIndex

FileEntry -> fileEntryIndex

The redirect will also contain a flash data named message that contains either:

modelname.undo.restored on success or modelname.undo.invalid when no model with the given ID could be found.

Customization

Don't like the auto generated routes? Don't like the auto generated model names? No problem!

Simply override them in your controller class like this:

You can also write your own undoDelete method, if you want some more control:

Contributing

Contributions are encouraged and welcome; to keep things organised, all bugs and requests should be opened in the github issues tab for the main project, at mpociot/reanimate/issues

All pull requests should be made to the develop branch, so they can be tested before being merged into the master branch.


All versions of reanimate with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
illuminate/database Version 5.*
illuminate/support Version 5.*
illuminate/events Version 5.*
illuminate/http Version 5.*
illuminate/routing Version 5.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mpociot/reanimate contains the following files

Loading the files please wait ....