错误照亮数据库Eloquent未找到

时间:2014-09-15 22:39:50

标签: php laravel laravel-4

在Controller中,当我试图从模型中调用函数时,它通过异常

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)

Class 'Illuminate\Database\Eloquent' not found

控制器很简单,我用来创建名称空间来管理子目录控制器和模型

<?php
namespace Manage ;
use Illuminate\Support\Facades\View;
use Illuminate\Routing\Controller;
class BaseController extends Controller {

    /**
     * Setup the layout used by the controller.
     *
     * @return void
     */
                    protected $layout = 'manage.layouts.master';
    protected function setupLayout()
    {
        if ( ! is_null($this->layout))
        {
            $this->layout = View::make($this->layout)->with(Dashboard::all());
        }
    }

}

和模型

<?php
namespace Manage ;
use Illuminate\Database\Eloquent;
class Dashboard extends Eloquent{
    protected $table = 'admin_dashboard_sidebar';
    //put your code here
}

2 个答案:

答案 0 :(得分:13)

该课程为Model:

use Illuminate\Database\Eloquent\Model as Eloquent;

或只是

use Eloquent;

最后一个是您在app/config/app.php中可以找到的课程的别名。

答案 1 :(得分:0)

use Illuminate\Database\Eloquent\Model;

class Dashboard extends Model{
}