Laravel - Pass more than one variable to view

前端 未结 11 1556
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 18:54

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 modif

11条回答
  •  眼角桃花
    2020-11-29 19:30

    For passing multiple array data from controller to view, try it. It is working. In this example, I am passing subject details from a table and subject details contain category id, the details like name if category id is fetched from another table category.

    $category = Category::all();
    $category = Category::pluck('name', 'id');
    $item = Subject::find($id);
    return View::make('subject.edit')->with(array('item'=>$item, 'category'=>$category));
    

提交回复
热议问题