jeudi 27 novembre 2014

Printing tasks per task list with Laravel 4 Eloquent


Vote count:

0




I'm trying to display several task lists in one page with their respective tasks. In my controller I'm using the following:



public function index()
{
$tasks_lists = Task_List::all();
$tasks = Task_List::find(1)->tasks;

return View::make('tasks.index', array(
'tasks' => $tasks,
'tasks_lists' => $tasks_lists
));
}


Using



$tasks = Task_List::find(1)->tasks;


Will return for all tasks lists the tasks appointed to task list 1. So I'm guessing here is my problem, what type of clause should I be using to achieve my goal?


My foreach in my view:



@foreach ($tasks_lists as $task_list)
<h2>{{ $task_list->title }}</h2>
<ul>
@foreach ($tasks as $task)
<li>
{{ Form::open() }}
<input type="checkbox" name="task" value="{{ $task->id }}" />{{ $task->name }}
{{ Form::close() }}
</li>
@endforeach
</ul>
@endforeach


asked 1 min ago







Printing tasks per task list with Laravel 4 Eloquent

Aucun commentaire:

Enregistrer un commentaire