Laravel 4 does not extend Eloquent class

[亡魂溺海] 提交于 2019-12-13 05:30:31

问题


I have a Product.php file in app/models folder. Here is the content of the file:

class Product extends Eloquent{
    protected $table = 'productinfo';
}

However, when I tried to run $product = Product::all();, Laravel say Call to undefined method Product::all(). It seems like Eloquent class is not extended.

I don't see anything I do wrong here. Why does it not working? Could it be any other configuration in Laravel which I mess up?

--update--

After renaming the Product.php file, it is now no longer showing error message. But the problem is, it does not properly return the result from database. Instead, the returned result is {"incrementing":true,"timestamps":true,"exists":true}. Not the result from database.

So, I tried to run a clean new Laravel project from composer and the only files that I modified is the config/database.php file to set it work with MySQL database, route.php file, and the models/Products.php file. When I browse it on browser, again it shows the same result: {"incrementing":true,"timestamps":true,"exists":true}, not database result.

I really don't know what causing it. I have tried with it in one my experiment Laravel project folder which has lots of junk in it, and it works perfectly fine here.

Do you know why it doesn't work? How to solve it?

Thank you.

来源:https://stackoverflow.com/questions/20061876/laravel-4-does-not-extend-eloquent-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!