【问题标题】:Laravel model returns error 404Laravel 模型返回错误 404
【发布时间】:2014-05-08 22:42:13
【问题描述】:

Laravel 4.1 中的模型问题

我有这个模型:

 class Blog extends Eloquent {
    protected $table = 'blog';
 }

和控制器:

 public function index(){
    $posts = Blog::all(); 
    return View::make('blog/index')->with('posts', $posts);
 }

我已经做了 artisan dump-autoload,但我总是得到:

error 404

我通过将变量传递给视图进行了一些测试,它可以正常工作,但不能使用博客模型。 真的不知道为什么,因为现在一切似乎都是正确的。

【问题讨论】:

  • 您收到 404 错误?是 Laravel 404 错误还是 Apache 404 错误?如果是 Laravel,我们还需要查看您的路线。
  • Nginx 错误 404 错误。路线很好。
  • 好吧,如果它是 404 则无法找到该页面。这和模型有什么关系?
  • 你不应该使用 View::make('blog.index') 而不是 View::make('blog/index') 吗?
  • 您的路线无效。接下来你应该得到一个 500 内部服务器错误。

标签: php laravel laravel-4 eloquent


【解决方案1】:

答案,迁移类中的名称重复。

【讨论】:

    猜你喜欢
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-17
    • 1970-01-01
    • 2014-01-26
    • 1970-01-01
    • 2015-02-14
    相关资源
    最近更新 更多