krafthaus / bauhaus

Laravel 4 Admin Generator
http://bauhaus.krafthaus.nl/
GNU General Public License v2.0
1 stars 0 forks source link

[feature request] Ability to change redirect after save/update/delete #26

Closed that0n3guy closed 10 years ago

that0n3guy commented 10 years ago

It would be nice to be able to change where the form redirects after save/update/delete. Useful if you have a create button on a dashboard and want to redirect back to the dashboard rather than the index.

There are lots ways to do this:

The first 2 are easy... not sure about the 3rd.

jspekken commented 10 years ago

(For completeness I've copied the pull-request comment here)

I think its better to do something like this:

// Create
public function beforeCreate($input);
public function creating($input);
public function afterCreate($model);

// Update
public function beforeUpdate($input);
public function updating($input);
public function afterUpdate($model);

// Delete
public function beforeDelete($model);
public function deleting($model);
public function afterDelete($model);

When you return a response in the after... methods (e.g. a redirect). That response object will be used instead of the one in the controller.

jspekken commented 10 years ago

Right now when you do this:

public function afterCreate()
{
    return Redirect::to('/');
}

The Response object will be executed after you create the model and you'll be redirected to the given route or url. This also works on afterUpdate and afterDelete