2014-01-06 20 views
6

をルーティングします。 PHPファイル:私は運と私のroutes.phpのファイルに以下のすべての可能性を試してみたLaravel RESTfulなコントローラは、私が私のURLにアクセスしようとしている

<?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'); 
    } 

} 

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'); 
}); 

他に提案がありますか?私は、これを成功させる方法についてはあまりよく分かりません。これらのルートすべてでエラーメッセージが表示されます。

コントローラのメソッドが見つかりません。もっとたくさんの周り掘りや記事の負荷を読んだ後、[OK]を

答えて

3

は、「最初に最初アウト」と呼ばれるこのルールがあります:

<?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'); 

したがって、ユーザーにつながるルートを持っている場合は、しかし、もっと深く行きたいなら、あなたのroutes.phpファイルに一番深いFIRSTを入れなければなりません!

ファンタスティック記事を読む:http://laravel.io/topic/30/routes-first-in-first-out

をによって回答:user3130415

+0

Upvotedリンクはここ – kJamesy

+0

@kJamesyがアーカイブからリンクされ壊れているが、http://web.archive.org/web/20130912011338/ http://laravel.io/topic/30/routes-first-in-first-out – Stranger

関連する問題