krafthaus / bauhaus

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

Doesn't know wher to redirect to if $model->afterStore/Updated/MultiDestroy not defined #43

Closed hackel closed 9 years ago

hackel commented 9 years ago

I discovered this issue within minutes of installing Bauhaus. It looks like this was probably added to address issue #26. Your scaffold command doesn't even add these methods to the generated models, and especially If you try to use it with an existing model, they will not be defined. Therefore these operations error out with "$redirect is undefined." This was easy to fix, e.g. in ModelController.php:188 like so:

$redirect = Redirect::route('admin.model.index', $name);
// afterMultiDestroy hook
return method_exists($model, 'afterMultiDestroy') ? $model->afterMultiDestroy($redirect) : $redirect;

This is definitely preferable to adding all those empty methods to my models when they are not needed.