在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
}
答案 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{
}