9

わかりました、私が使用する完全なroutes.phpファイル...私はちょうどここにそれを貼り付けました:http://pastebin.com/kaCP3NwK

ルート.php

//The route group for all other requests needs to validate admin, model, and add assets
Route::group(array('before' => 'validate_admin|validate_model'), function()
{
    //Model Index
    Route::get('admin/(:any)', array(
        'as' => 'admin_index',
        'uses' => 'admin@index'
    ));

管理者設定:

...
'models' => array(
'news' => array(
    'title' => 'News',
    'single' => 'news',
    'model' => 'AdminModels\\News',
),
...

リンクジェネレータ:

@foreach (Config::get('administrator.models') as $key => $model)
    @if (Admin\Libraries\ModelHelper::checkPermission($key))
        <?php $key = is_numeric($key) ? $model : $key; ?>
        <li>
            {{ HTML::link(URL::to_route('admin_index', array($key)), $model['title']) }}
        </li>
    @endif
@endforeach

controllers / admin.php

public function action_index($modelName)
{
    //first we get the data model
    $model = ModelHelper::getModelInstance($modelName);

    $view = View::make("admin.index",
        array(
            "modelName" => $modelName,
        )
    );

    //set the layout content and title
    $this->layout->modelName = $modelName;
    $this->layout->content = $view;
}

したがって、にアクセスhttp://example.com/admin/newsすると...newsに送信されaction_indexますが、何らかの理由でそこに到達せず、返されます404

4

2 に答える 2

5

次のように定義したことに注意してください'model' => 'AdminModels\\News',

実際に私のnamespaceレジスターがあったとき、それで404の私の問題のためにAdmin\Modelsそれを設定します'model' => 'Admin\Models\\News',

于 2013-01-08T16:22:17.640 に答える
3

ルートは登録された順序で評価されるため、(:any)ルートは最後である必要があります。あなたはadmin@indexに送られている(私は思う)-その関数がまだ定義されていない場合、それがあなたが404を受け取っている理由です。

于 2013-01-04T20:37:54.343 に答える