此集合实例laravel上不存在Property [id]

时间:2017-10-31 08:08:55

标签: php laravel

我修复了刚刚放入的新代码后仍然遇到此错误,我不知道为什么它会给我这个错误"此集合实例上不存在Property [id]"这指向home.blade.php中我的路线的id。有人可以帮我看看,非常感谢

我添加的部分是hire_status部分,在修复之后,它给了我这个错误。 home.blade.php

    <table class="table table-bordered">
      <tr>
        <th><strong><big>Name: </big></strong></th>     
        <th><strong><big>Hire Status: </big></strong></th>  
        <th><strong><big>Action: </big></strong></th>
      </tr>
      <td>
      <tr>
        @foreach($data as $value)
      <tr>    
      <th><a href="{{route('user.show',['id'=>$value->id])}}">{{$value->Name}}</a></th>
    <th> 
      @foreach($data1 as $value1)

      {{$value1->hire_status}}

   </th>
      <th><form action="{{  url('/home/'.$value->id.'/delete')  }}" method="get">
        {{ csrf_field() }}
        <button type="submit">Delete</button>
      </form></th>              
      </tr>
      @endforeach
         @endforeach
      </tr>
      </tr>
    </table>

HomeController中:

    public function getData(){
        $data['data'] = DB::table('personal_infos')->where('deleted_at',NULL)->get()->sortByDesc('created_at');
        $data1 = DB::table('hires')->where('hire_status','Yes')->get();

        if(count($data)>0){
        return view('home',compact('data','data1'));
    }else{
    return view('home');
}
}

1 个答案:

答案 0 :(得分:1)

只需从数组中删除键, 您正试图直接在视图中获取数据,因此直接获取数据数据...

private void showResult(){
        try {
            JSONObject jsonObject = new JSONObject(mJsonString);
            JSONArray jsonArray = jsonObject.getJSONArray(TAG_JSON);


            for(int i=0;i<jsonArray.length();i++){

                JSONObject item = jsonArray.getJSONObject(i);

                String id = item.getString(TAG_ID);
                HashMap<String,String> hashMap = new HashMap<>();
                hashMap.put(TAG_ID, id);

                String aa = hashMap.get("user_no");

                mArrayList.add(hashMap);
            }

        }
    }

将其更改为,

$data['data'] = DB::table('personal_infos')->where('deleted_at',NULL)->get()‌​->sortByDesc('create‌​d_at');