You can use controller routing :)
class UserController extends BaseController {
/**
* Instantiate a new UserController instance.
*/
public function __construct()
{
$this->beforeFilter('@filterRequests');
}
/**
* Filter the incoming requests.
*/
public function filterRequests($route, $request)
{
//
}
}
rcrocks said:
You can use controller routing :)
This still doesn't solve the problem.
I managed to create a work around for the problem
I put the query logic in my model and cache the result
public function scopeByUrl($query, $url)
{
// cache the data for 15 minutes
return Cache::remember('domain_by_url_'.$url, 15, function() use ($query, $url)
{
return $query->with('account.domains')->where('url', '=', $url)->first();
});
}
and request it in both the filter and controller like so
$domain = Domain::byUrl(Request::server('HTTP_HOST'));
By caching the result the queries do not run twice... I wonder if I could store the result in the model though...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community