【发布时间】:2014-03-04 19:20:58
【问题描述】:
控制器类-
<?php
class PageController extends BaseController {
public function home ()
{
$var = Testrundetail::getAll();
return View::make('hello')->with('name', $var);
}
public function about ()
{
return View::make('about');
}
}
模型类-
class Testrundetail extends Eloquent {
protected $table = 'testrundetail'
public function getAll ()
{
$getAll = Testrundetail::all();
return $getAll;
}
}
路线
Route::get('/', 'PageController@home');
Route::get('/about', 'PageController@about');
你好.blade.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1> Hello, {{ $var }} </h1>
</body>
</html>
我收到了错误 -
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Testrundetail' not found
1. Symfony\Component\Debug\Exception\FatalErrorException
…\app\controllers\PageController.php7
代码有什么问题?? :(
【问题讨论】:
-
您的 Testrundetail 模型是否已自动加载?
-
你在哪里存储 Testrundetail.php ?在
app/models/目录中? -
@WebNovice 是的 testrundetail.php 在 app/model 目录中
-
@SergioAristizábal 自动加载?我是这里的新手.. 请用 lil 解释说明
-
@SergioAristizábal 是这样的吗??
codefideloper.com/…code*.com/questions/17584810/…??