Trying to run the following Laravel 4.1 route: http://myserver.dev/admin/import-items/1
When I do so, I get the following error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method not found.
Here are my routes for this:
Route::group(array('prefix' => 'admin', 'before' => 'auth'), function()
{
Route::get('items/import-items/{after?}', array('as' => 'importItems', 'uses' => 'ItemsController@importItems'));
Route::get('items/{id}/show', 'ItemsController@show');
Route::resource('items', 'ItemsController');
});
I can look at the Items controller, and the method importItems
is most definitely there:
class ItemsController extends \BaseController {
/**
* Item Model
* @var Item
*/
protected $item;
/**
* Inject the models.
* @param Item $item
*/
public function __construct(Item $item)
{
parent::__construct();
$this->item = $item;
}
/**
* Display a listing of items
*
* @return Response
*/
public function index($items = [])
{
$title = Lang::get('admin/items/title.manage_items');
if (empty($items))
$items = $this->item;
return View::make('admin/items/index', compact('items', 'title'));
}
/**
* Imports Items after specified date.
* @return array
**/
public function importItems($after = 7)
{
$results = Item::importItems($after);
return $results;
}
}
When I run php artisan routes
the route clearly shows up as usable in the list:
GET|HEAD admin/items/import-items/{after?} | importItems | ItemsController@importItems
The thing is, this exact code works just fine from another project I had it in. After I copied over the route settings and the controller and model, it decided not to work in this new project. I feel like I've missed some key step here because I can't see any differences in the code.
Any ideas?