2014-06-13 07:46
浏览 156


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');

        '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?


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.

图片转代码服务由CSDN问答提供 功能建议

我想在主视图(show)中显示票证(视图)的动态数量。 我从数据库中获取了一系列故障单数据。 问题是 laravel 不允许我从视图中回显视图(也许它可能?并且有人知道怎么做)所以我在控制器中创建了一系列票证视图并将它们传递给我的主视图 (节目)。 在主视图中,我使用 foreach 来运行所有视图并显示它们。 由于某种原因 laravel 抛出错误方法Illuminate \ View \ View :: __ toString()不得抛出异常。 这意味着我的观点有问题。 我做错了什么?


  foreach($ ticket as $ ticket)  {
 $ oldTickets [] = View :: make('helpers.eventBox',array('ticket'=> $ ticket)); 
 $ layout = View :: make('  layouts.main'); 
 $ layout-> nest('content','',array(
'oldTickets'=> $ oldTickets,
 \  n返回$ layout; 


  foreach($ oldTickets 作为$ ticket){
 echo $ ticket;  

当我将单个视图从控制器传递到视图时,它可以工作。 我的问题是什么? 什么是最好的解决方案?


编辑: 我的视图中有错误。 通常可以从视图页面渲染。 我解决了我的问题。

刀片解决方案看起来也是正确的方式,我尝试但没有成功,如果我会在你的答案附近看到5'上升点'我会标记它 对于会遇到同样问题的其他用户来说,这是一个正确的问题。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题