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 trialRobert Young
11,742 PointsBadMethodCallException 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
1 Answer
Alexander Siclari
3,852 PointsLaravel 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.
Thiago van Dieten
16,639 PointsThiago van Dieten
16,639 PointsDoes your TodoListController.php (where the class TodoListController is located I presume) actually have an function called all?