2015-03-21 10:51
浏览 22


I have the following code in my view page

 <form action="{{ action('AnswerController@handleCreate') }}" method="post" role="form">
        <div class="form-group dropdown">
            <label for="question">Question</label>
            <select  id="question" class="drop" name="question">
                @foreach($questions as $question)

                    <option value="{{$question->question}}">{{$question->question}}</option>


in my controller i have the following code

$question = Question::whereQuestion(Input::get('question'))->first();

$n = $question->id;

They give me an error at $n=$question ->id telling trying to get property of non-object

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


 &lt  ; form action =“{{action('AnswerController @ handleCreate')}}”method =“post”role =“form”&gt; 
&lt; div class =“form-group dropdown”&gt; 
&lt; label  for =“question”&gt;问题&lt; / label&gt; 
&lt; select id =“question”class =“drop”name =“question”&gt; 
 @foreach($ questions as $ question)
&lt  ; option value =“{{$ question-&gt; question}}”&gt; {{$ question-&gt; question}}&lt; / option&gt; 
&lt; / select&gt; 
&lt;  / div&gt; 


  $ question = Question :: whereQuestion( 输入:: get('问题')) - &gt; first(); 
 $ n = $ question-&gt; id; 

他们给出 我错误$ n = $ question - &gt; id告诉我试图获取非对象的属性

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

1条回答 默认 最新

相关推荐 更多相似问题