Laravel 4.2第一个模型连接到Eloquent

时间:2014-10-03 01:40:26

标签: php debugging laravel laravel-4 routes

所以这是我第一次使用 Laravel v4.2

令人困惑,因为error.log信息非常小。

我想创建一个名为Author

的新模型

这是我的 routes.php

Route::get('authors', 'AuthorsController@IndexAction');

这是我的 AuthorsControllers.php

<?php

class AuthorsController extends BaseController {

    public $restful = true;
    public $layout = 'layouts.default';

    public function indexAction(){
        return  View::make('authors.index')
            ->with('title', 'Authors and Books')
            ->with('authors', Author::all())
            ;
    }

    public function getView($id){
        return View::make('authors.view')
            ->with('title', 'Author View Page')
            ->with('author', Author::find($id))
            ;
    }
}

这是我的 Author.php

<?php
class Authors extends Eloquent {
}

我收到了这个错误日志

[20

14-10-03 01:37:43] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Author' not found' in C:\xampp\htdocs\laravel-master\app\controllers\AuthorsController.php:11
Stack trace:

#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()

#1 {main} [] []

我想知道问题出在哪里?因为我已经关注了所有这个链接页面 http://laravel.com/docs/4.2/quick#creating-a-view

请记住,我使用作者创建了控制器,并使用作者创建了模型。

1 个答案:

答案 0 :(得分:1)

您需要更改

class Authors extends Eloquent {

class Author extends Eloquent {

可能需要在进行更改后运行composer dump-autoload(我无法记住)