doupengxie4195 2013-11-21 01:31
浏览 123
已采纳

Laravel - 传递多个变量进行查看

I have this site and one of its pages creates a simple list of people from the database. I need to add one specific person to a variable I can access.

How do I modify the return $view->with('persons', $persons); line to also pass the $ms variable to the view?

    function view($view)
    {
        $ms = Person::where('name', 'Foo Bar');

        $persons = Person::order_by('list_order', 'ASC')->get();

        return $view->with('persons', $persons);
    }
  • 写回答

10条回答 默认 最新

  • duandingqi9442 2013-11-21 01:47
    关注

    Just pass it as an array:

    $data = [
        'name'  => 'Raphael',
        'age'   => 22,
        'email' => 'r.mobis@rmobis.com'
    ];
    
    return View::make('user')->with($data);
    

    Or chain them, like @Antonio mentioned.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(9条)

报告相同问题?

悬赏问题

  • ¥15 三菱FX系列PLC串口指令
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!
  • ¥15 关于自相关函数法和周期图法实现对随机信号的功率谱估计的matlab程序运行的问题,请各位专家解答!
  • ¥15 Python程序,深度学习,有偿私
  • ¥15 扫描枪扫条形码出现问题
  • ¥35 poi合并多个word成一个新word,原word中横版没了.
  • ¥15 【火车头采集器】搜狐娱乐这种列表页网址,怎么采集?
  • ¥15 求MCSCANX 帮助
  • ¥15 机器学习训练相关模型
  • ¥15 Todesk 远程写代码 anaconda jupyter python3