laravel 错误 Illuminate Database Eloquent Not Found

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25857979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:06:25  来源:igfitidea点击:

Error Illuminate Database Eloquent Not Found

phplaravellaravel-4

提问by Dr.Neo

In the Controller when i tried to call a function from a model it Through Exception

在控制器中,当我尝试通过异常从模型调用函数时

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

Class 'Illuminate\Database\Eloquent' not found

the controller is simple and i used to create name space to manage sub directories controllers and model

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

<?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());
        }
    }

}

and model

和模型

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

回答by Antonio Carlos Ribeiro

The class is Model:

该类是模型:

use Illuminate\Database\Eloquent\Model as Eloquent;

or just

要不就

use Eloquent;

This last one is an alias to the class you can find in your app/config/app.php.

最后一个是您可以在app/config/app.php.