I think that I bumped into a small 'bug' or I am missing something (eg. to define the order of the routes). I created the following annotations in a controller:
/**
* @Resource("projects", only={"index", "create", "store"})
* @Before("csrf", on={"post", "put", "delete"})
*/
class ProjectsController {
/**
* Display a listing of the all projects for the signedin user.
*
* @Before("auth")
* @return Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new project.
*
* @Before("auth")
* @return Response
*/
public function create()
{
//
}
/**
* Store a newly created project.
*
* @Before("auth")
* @param CreateProjectRequest $request
* @return Response
*/
public function store(CreateProjectRequest $request)
{
//
}
/**
* Show the Project.
*
* @Before("auth")
* @Get("projects/{project}", as="projects.show")
*/
public function show($project)
{
//
}
}
After running php artisan route:scan the routes are generated, however the order of the routes is not correct resulting in the fact that you can't access the route of the project show method:
$router->get('projects/{project}', ['uses' => 'Jonril\Http\Controllers\ProjectsController@show', 'domain' => NULL, 'as' => 'projects.show', 'before' => array (
), 'after' => array (
), 'where' => array (
)]);
$router->group(['before' => array (
0 => 'auth',
), 'after' => array (
), 'prefix' => NULL, 'domain' => NULL, 'where' => array (
)], function($router) { $router->resource('projects', 'Jonril\\Http\\Controllers\\ProjectsController', ['only' => array (
0 => 'index',
), 'names' => array (
)]); });
$router->group(['before' => array (
0 => 'auth',
), 'after' => array (
), 'prefix' => NULL, 'domain' => NULL, 'where' => array (
)], function($router) { $router->resource('projects', 'Jonril\\Http\\Controllers\\ProjectsController', ['only' => array (
0 => 'create',
), 'names' => array (
)]); });
$router->group(['before' => array (
0 => 'csrf',
1 => 'auth',
), 'after' => array (
), 'prefix' => NULL, 'domain' => NULL, 'where' => array (
)], function($router) { $router->resource('projects', 'Jonril\\Http\\Controllers\\ProjectsController', ['only' => array (
0 => 'store',
), 'names' => array (
)]); });
The first route projects/{project} should not be at the top, due to this you can't access projects/create, this might be a bug, or something I'm missing (eg. how to define the order of the routes).