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 trialChun Yu Lim
3,200 Pointsi am stuck undefined variable
i am having a hard time with Laravel Framework 5.7.9
keep giving me lots of error message anybody can assist?
this error i am not able to resolve ErrorException (E_ERROR) Undefined variable: todo_lists (View: /home/vagrant/laravel/resources/views/todo/index.blade.php)
@extends('layouts.main') @section('content')
<h2>show All Todo lists</h2>
<?php var_dump($todo_lists) ?> <ul> <li>List One</li> </ul>
@stop
this is highlighted as the main cause of the error <?php var_dump($todo_lists) ?>
please assist.
2 Answers
Spenser Hale
20,915 PointsHello Chun Yu Lim,
In order to have values in your views, you will need to have the controller pass them to the view.
<?php
view('todo.index')->with('todo_lists', ['My First Task','2nd Todo']);
Erwin Fung
82 Pointsyou need pass a variable from your controller to view. user with or compact