使用未定义的常量品牌-假设为“品牌" [英] Use of undefined constant makes - assumed 'makes'

查看:148
本文介绍了使用未定义的常量品牌-假设为“品牌"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的laravel项目中有以下route

 Route::get('/',[

   'uses' => 'MakeController@index'

  ]);

Controller

   class MakeController extends Controller{


    public function index(){

        $makes = MakeType::all();        
        return View::make('Index', $makes);
        // tried this
        //  return view('Index',compact('makes'));
    }
}

index.blade.php

<select>
       <option>Select Make</option>
             @foreach($makes as $make)

                 <option>{{$make->name}}</option>

             @endforeach
</select>           

问题:

问题是当我尝试加载index页面时,它显示了以下错误

The problem is when I try to load the index page, it shows me the following error

使用未定义的常量make-假定为"makes"(这将在以后的PHP版本中引发错误)(查看:/customers/6/1/4/alle-voertuigen.nl/httpd.www/resources/views/Index.blade.php)

Use of undefined constant makes - assumed 'makes' (this will throw an Error in a future version of PHP) (View: /customers/6/1/4/alle-voertuigen.nl/httpd.www/resources/views/Index.blade.php)

我已经访问了所有可能的链接,并尝试了不同的方法,但没有任何帮助.

I've visit all the possible links, and tried different ways of doing it, but nothing is working with me.

这是我执行dd($makes)时显示的内容,在attributes中我有name

This is what it is showing when I do dd($makes), in attributes I have the name column

请帮助我,谢谢

推荐答案

在控制器中使用with.

return View::make('Index')->with(compact('makes'));

应该工作.

这篇关于使用未定义的常量品牌-假设为“品牌"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆