我正在Laravel 4.2中创建一个应用程序,当我创建一个模型时,我得到一个例外,它没有找到:
models / Annulations.php:
class Annulation extends Eloquent {
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'annulation_remboursement';
controllers / AnnulationsController.php:
class AnnulationsController extends \BaseController {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$annulations = Annulation::all();
return View::make('Annulations.index')->withAnnulations($annulations);
}
在stackoverflow上,我找到了关于命令的解决方案:
$ php artisan dump-autoload
如果我尝试此命令,那么我仍然有这个错误: 未找到“Annulation”类
你能帮帮我吗?
答案 0 :(得分:0)
如果您创建模型 Annulations ,则您的班级应为class Annulations
。
例如:
文件夹路径: models / Annulations
class Annulations extends Eloquent{
//logic here
}
在您的控制器中:
public function someController(){
$annulations = Annulations::all(); //call your model
print_r($annulations); //print to check if data exists
return View::make('Annulations.index')->withAnnulations($annulations);
}