No one?
Using a filter in a package
Since Laravel 4.3 is coming I started creating a package in the Dev branch of laravel. Now everything works like a charm the only thing I bumb in to is that I need to use a Filter defined in my Package folder to check the filter in my controller. but it can't find it.
VisitorFilter.php
<?php namespace Woodmarks\Mila\Http\Filters;
use Auth, Redirect;
class VisitorFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
if (Auth::check())
{
return Redirect::to('Woodmarks\Mila\Http\Controllers\Auth\AuthController@getLogin');
}
}
}
And in my controller AuthController.php
public function __construct (Authenticator $auth) {
$this->auth = $auth;
$this->beforeFilter('csrf', ['on' => ['post']]);
$this->beforeFilter('visitor', ['except' => ['getLogout']]);
}
But it can't find the visitor filter. Should i register the filter in my service provider or something? Or should i add a namespace to the beforeFilter?
Checkout this class. Laravel's filter service provider class extends this.
https://github.com/laravel/framework/blob/master/src/Illuminate/Routing/FilterServiceProvider.php
You will still need to register your own service provider(s) in the configuration, but you can probably add your own filters replicating how Laravel adds them.
Please or to participate in this conversation.