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 trialdorino canciani
2,265 PointsProblem with Eloquent ORM
So this is code in TodoListController.php file
<?php
public function index(){
$todo_lists = TodoList::all();
return view('todos/index')->with('todo_lists', $todo_lists);
}
<?php
Route::get('/', 'TodoListController@index');
<?php
class TodoList extends Eloquent{}
This is the output of DB::select('show tables;');
[{"Tables_in_odot":"migrations"},{"Tables_in_odot":"password_resets"},{"Tables_in_odot":"todo_lists"},{"Tables_in_odot":"users"}]
I have added two rows in todo_lists table manually with sequel pro
I'm wondering why it returns a blank page with no data. Could you help me please?
3 Answers
Christopher Rebacz
10,904 PointsWhat does your view 'todos/index' look like? Since you mentioned it is only a blank page, with no exceptions being thrown by Laravel, it seems to be finding everything that it is expecting to find.
Do you have something akin to:
<ul>
@foreach ($todo_lists as $list)
<li>{{$list->name}}</li>
@endforeach
</ul>
in your view?
dorino canciani
2,265 PointsI deleted php tags but still don't work
@extends('layouts.main')
@section('content')
<h2>All Todo Lists</h2>
<ul>
<?php
@foreach ($todo_lists as $list)
<li>{{$list->name}}</li>
@endforeach
?>
</ul>
@stop
It seems that the problem is in $todo_lists = TodoList::all(); in TodoListController.php but i can't figure why
dorino canciani
2,265 Pointsok i solved. i made a mistake in the installation process.
Christopher Rebacz
10,904 PointsCool. Glad you figured it out.
dorino canciani
2,265 Pointsdorino canciani
2,265 PointsIt seems stat TodoList::all() causes the problem but i can't understand why