Domanda

Ok, the full routes.php file that I use... I just pasted it here: http://pastebin.com/kaCP3NwK

routes.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'
    ));

administrator config:

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

links generator:

@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;
}

So, when accessing http://example.com/admin/news the news is sent to action_index... but for some reason it doesn't get there and it returns 404

È stato utile?

Soluzione

Notice that I defined the following 'model' => 'AdminModels\\News',

when actually my namespace register was Admin\Models, so setting it to 'model' => 'Admin\Models\\News', for my issue for the 404

Altri suggerimenti

Routes are evaluated in the order that they're registered, so the (:any) route should be last. You're being sent (I think) to admin@index -- if that function isn't defined yet, that's why you're getting a 404.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top