gpt4 book ai didi

php - Laravel调试404路由

转载 作者:可可西里 更新时间:2023-11-01 12:17:59 25 4
gpt4 key购买 nike

好的,我使用的完整 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

Controller /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

最佳答案

请注意,我定义了以下 'model' => 'AdminModels\\News',

实际上我的 namespace 寄存器是 Admin\Models,所以将它设置为 'model' => 'Admin\Models\\News', 我的 404 问题

关于php - Laravel调试404路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14160202/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com