I'm trying to access my URL at:
www.mysite.com/user/dash/sales
I have in my controllers directory, a DashboardController.php file:
<?php
class DashboardController extends BaseController {
public function __construct() {
$this->beforeFilter('auth');
}
/**
* Supplier's dashboard screen
*
*/
public function getSupplier()
{
$this->layout->content = View::make('user.dashboard.supplier');
}
/**
* Sales dashboard screen
*
*/
public function getSales()
{
$this->layout->content = View::make('user.dashboard.sales');
}
/**
* Admin's dashboard screen
*
*/
public function getAdmin()
{
$this->layout->content = View::make('user.dashboard.admin');
}
}
I've tried all the following possibilities in my routes.php file with no luck:
Route::any('user/dash/(:any)', array('uses' => 'DashboardController') );
Route::controller( 'user/dash', 'DashboardController' );
Route::group(array('prefix' => 'user', 'before' => 'auth'), function()
{
Route::controller('dash', 'DashboardController');
});
Does anyone have any other suggestions? I'm not quite sure on how to make this a successful route. The error message I get with all those routes is this:
Controller method not found.
Ok after a lot more digging around and reading loads of articles, there is this rule called "first in, first out":
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
/** RESTful Controllers **/
Route::controller( 'user/dash', 'DashboardController' );
Route::controller( 'user', 'UserController' );
Route::controller( 'product', 'ProductController' );
Route::group(array('prefix' => 'dash', 'before' => 'auth'), function()
{
Route::controller('product', 'Dash_ProductController');
Route::controller('user', 'Dash_UserController');
});
/** Home/Fallback Controller **/
Route::controller('/', 'HomeController');
So therefore if you have a route leading to user, but then want to go deeper, you have to put the deepest FIRST in your routes.php file!
Fantastic article read : http://laravel.io/topic/30/routes-first-in-first-out
Answered By: user3130415
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With