Extender Resource Controllers

3

I'm doing what I want in a way and I'm looking for alternatives or better ways to do it. I am using Resource Controllers in my application. I'm also using softdelete in many models, so my routes look like this:

Route::get('users/deleted', array('uses' => 'UserController@trash'));
Route::put('users/{id}/restore', array('uses' => 'UserController@restore'));
Route::resource('users', 'UserController');

The first route is to display the ones that have been deleted. The second one allows me to restore these deleted items. The third one maps the traditional methods (create, edit, update etc).

What happens is that since I have several controllers that work exactly the same way, I would like to know if there is any way to tell laravel that when I have a Resource Controller, the restore and trash methods work on the requests in the above patterns .

Is it possible? Or is it better to do what I'm doing?

    
asked by anonymous 21.03.2014 / 14:24

1 answer

1
  

Based on this post from the Laravel forum you can solve this.

class MyRouter extends \Laravel\Routing\Router {}
  

app / config / app.php   

'aliases'   => array( 
//--//
Route'  => 'MyRoute'
//--//
);
  

I did not test the solution to see if it works 100%, but I believe you can create all the methods you want as well.

    
21.03.2014 / 16:18