Ale*_*lex 9 php http-status-code-404 laravel laravel-routing
好的,routes.php我使用的完整文件...我只是粘贴在这里:http://pastebin.com/kaCP3NwK
//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'
));
Run Code Online (Sandbox Code Playgroud)
管理员配置:
...
'models' => array(
'news' => array(
'title' => 'News',
'single' => 'news',
'model' => 'AdminModels\\News',
),
...
Run Code Online (Sandbox Code Playgroud)
链接生成器:
@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
Run Code Online (Sandbox Code Playgroud)
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;
}
Run Code Online (Sandbox Code Playgroud)
所以,当访问http://example.com/admin/news将news被发送到action_index......,但由于某种原因,它不到达那里和返回404
请注意,我定义了以下内容 'model' => 'AdminModels\\News',
实际上我的namespace寄存器是Admin\Models,所以将它设置'model' => 'Admin\Models\\News',为我的 404 问题
| 归档时间: |
|
| 查看次数: |
5489 次 |
| 最近记录: |