Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Laravel 4 Basics Laravel and Databases Eloquent ORM

BadMethodCallException in compiled.php line 8295: Method [all] does not exist.

Hi, I am trying to add the following line of code to my controller file, and I keep on receiving the above error.

//TodoListController.php

public function index() { $todo_lists = TodoListController::all(); return View::make('todos.index')->with('todo_lists', $todo_lists); }

Please help!!

Robert

Thiago van Dieten
Thiago van Dieten
16,639 Points

Does your TodoListController.php (where the class TodoListController is located I presume) actually have an function called all?

1 Answer

Laravel 5.4 is a little bit different as far as syntax:

public function index() { $todo_lists = \App\TodoList::all(); return view('todos.index')->with('todo_lists', $todo_lists); }

Because of how namespacing works, you need to put \App\ before the name of the controller and function.