Tuesday, 15 January 2013

php - Eloquent method all() undefined -


Hi, I'm learning laravel recently I'm experiencing a problem It seems that the eloquent method inherits the right legacy. Not found in When I tried to get all the data from one table in my controller index method, it calls the "undefined method category :: all ()" .. It's something disturbing that I had never done before as I The code did the same way. I pasted my code below, pls need to ur attention.

Model:

  & lt ;? Php class category is extended \ eloquent {// protected $ fillable = []; Protected $ table = 'categories'; Public static function getCategory ($ category) {$ category- & gt; Category = $ range ['category']; $ Range & gt; Save (); }}  

Controller:

  Public function index () {// get all inputs $ categories = category :: all (); // Load the view and return the input View: create ('Management category') - & gt; With ('categories', $ ranges); }  

View:

  & lt; Div class = "col-md-4" & gt; & Lt; Select name = 'category' class = "table-group-action-input form-control" name = "product [status]" & gt; & Lt; Options & gt; Select & lt; / Options & gt; @if (isset ($ categories)) @foreach (categories as categories) & lt; Option value = "{{$ categories-& gt; id}}" & gt; {{$ Categories- & gt; Category}} & lt; / Options & gt; @adornach @ atif & lt; / Select & gt; & Lt; / Div & gt;  

route:

  Root :: find ('/ management-category', 'category controller @ index');  

Most likely your musician autoload definition is outdated and therefore your controller is not class Searched class. You should try to run the composer dump-autoload command from your project directory and see if it fixes your problem before it is checked.

Please note, Laravel 4 does not automatically load your models (or later any non-controller library classes included), so every time you are adding model class to your project , Then you have to run the composer dump-autoload command from your project directory.


No comments:

Post a Comment