duanliao2310 2015-04-12 12:55 采纳率: 100%
浏览 44
已采纳

Laravel 5将变量从控制器传递到视图

I'm new to php platforms and what I'm trying to do is to pass a variable from the controller to view for populating a dropdown list with entries from the database, but whatever i'm trying is not working. I get the following error:

Undefined variable: products_create

I can't understand what I'm doing wrong.

Controller

public function create()
{
    $products_create = categories::all(['id', 'category']);

    return View::make('products.create', compact('id', 'category'));
}   

View

{!! Form::label('category', 'Categorie') !!}
{!! Form::select('category', $products_create) !!}
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 在matlab中如何进行三个参数的离散傅里叶逆变换(idft)
      • ¥15 遇到问题了,求解答!
      • ¥15 请问coppliasim eduUR5视觉抓取怎么实现仿真,
      • ¥30 JavaWeb实验(购物平台)
      • ¥15 八路抢答器倒计时设计时显示器不输出,只能显示0
      • ¥15 用C语言随机生成一个迷宫
      • ¥15 超多因素的正交方案设计
      • ¥15 Scratch~汽车小游戏
      • ¥30 OSGB转换为3dtiles
      • ¥25 用于Audio的芯片中“Audio Interface”和“Mode Control”是什么?