有人可以帮助,为什么第一个$ eq会导致500错误? 提前谢谢。
routes.php文件
Route::get('page', function()
{
$eq = Equip_for_sale::all(); // Not Working !
$eq = DB::table('equip_for_sale')->get(); // Working !
return View::make('page')->with('eq', $eq);
});
模型/ Equip_for_sale.php
class Equip_for_sale extends Eloquent {
protected $table = 'equip_for_sale';
}
视图/ page.php文件
var_dump($eq);
答案 0 :(得分:2)
Laravel希望StudlyCaps
班级名称Laravel
符合PSR
编码标准。
根据PSR
编码风格:
Class names MUST be declared in StudlyCaps and Method names MUST be declared in camelCase.
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
所以,
class EquipForSale extends Eloquent {
protected $table = 'equip_for_sale';
}
并在您的控制器中:
$eq = EquipForSale::all();