我正在尝试学习一些关于 Laravel4 框架的知识,所以我决定使用
php artisan controller:make ProductsController
.
不幸的是,运行该应用程序后,我收到此错误消息:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Products' not found","file":"\/Applications\/MAMP\/htdocs\/shoppingCart\/app\/controllers\/ProductsController.php","line":14}}
有人知道我该如何解决吗?提前致谢。
以下是相关代码:
1)我的路线:
Route::get('/', function()
{ return View::make('home');});
Route::resource('products','ProductsController');
2)控制器:
class ProductsController extends BaseController {
public function index()
{
return Products::all()->toArray();
}
etc...
3) 型号:
Class Products extends Eloquent{
protected $table = 'products';}
我也做过composer dump-autoload