I want show dynamic numbers of tickets (views) in my main view (show). I get an array of tickets data from the database. The problem is that laravel
don't allow me echo view from view (maybe it possible? and somebody knows how make it) so I create array of tickets views in the controller and pass them to my main view (show). In the main view I use foreach
to run over all the views and show them. for some reason laravel
throws error Method Illuminate\View\View::__toString() must not throw an exception
. it means that something wrong with my views. What am I doing wrong?
My Controller Code:
foreach( $tickets as $ticket ){
$oldTickets[] = View::make('helpers.eventBox', array( 'ticket' => $ticket ));
}
$layout = View::make('layouts.main');
$layout->nest('content','profile.show.show',array(
'oldTickets' => $oldTickets,
));
return $layout;
Show View:
foreach( $oldTickets as $ticket ){
echo $ticket;
}
When I pass single view from controller to the view it works. What can my problem be? What is the best solution for it?
Thanks.
EDIT: I had bug in my view. generally it possible to render from view page. I fix my issue.
the blade solution looks like right way too, I try it but don't success, if I will see 5 'up points' near your answer I will mark it as a right question for other users that will have same issue.
sorry and thanks for the help.