好的,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
控制器/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