laravel/laravel — Issue #190: [Request] Route to controller, result returned back to route
Author: jaysonic
Created: 2011-12-02 08:54:12+00:00
State: open

I'd like to no what others think of this as well.

Basically I have a few similar routes where the owner of the website is confirmed, and then if the website belongs to them it makes use of the website variable. Example:

~~~~
$website = App\Website::find(1);

if(User::id() != $website->user_id)
{
// Does not belong to this user.
}

// Hand off to a view, make use of the $website variable
~~~~

There's a few of those and a few others where the same code is written. What I was interested in doing is using a controller from the route and then having the response returned back to the route.

~~~~
'GET /user/website' => array('uses' => 'user@website', function($website)
{
// Hand off to view because the controller dealt with confirming the user ownership and has returned the website object
}
~~~~

Of course this sounds like filters, so if filters could implement this kind of functionality it would be really neat.

Basically I'm trying to eliminate repeating myself in a few places. I want to maintain all these routes and not have to switch over for controllers with a few of them because then it'll just get frustrating.

I'm open to other ideas and suggestions though.