2

I want to protect only POST requests to my index, how can I do it?

public $restful = true;

public function __construct()
{
    parent::__construct(); 
            //this does not work
    $this->filter('before', 'auth')->only(array('post_index'));
}

public function get_index()
{
            //I do not want to protect this
    return Response::eloquent(Model::all()); 
}

public function post_index()
{
            //I want to protect only this call
}
4

1 に答える 1

4

You're almost there! If you only want to protect the POST request, use a combination of the only() and on() methods. Try:

$this->filter('before', 'auth')->only('index')->on('post');

Here's the api page for reference.

于 2013-02-14T00:49:37.040 に答える