Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
试图获得财产';名称';非对象的定义?我用弹拨的时候 正在尝试获取非对象的属性“name”?当我使用pull()从数据库检索数据时 //a、 控制器 公共职能指数(){ $insurance=insurance_Providers::pull('id','name'); $medicines=medicines::pull('id','pp','sp'); $pharmacies=pharmacies::pull('id','name'); 返回视图('auth.profile',compact('insurance','medicines','pharmacies'); } //a、 blade.php 保险商 @foreach($pro保险){{{$pro->name} @endforeach_Php_Laravel 5 - Fatal编程技术网

试图获得财产';名称';非对象的定义?我用弹拨的时候 正在尝试获取非对象的属性“name”?当我使用pull()从数据库检索数据时 //a、 控制器 公共职能指数(){ $insurance=insurance_Providers::pull('id','name'); $medicines=medicines::pull('id','pp','sp'); $pharmacies=pharmacies::pull('id','name'); 返回视图('auth.profile',compact('insurance','medicines','pharmacies'); } //a、 blade.php 保险商 @foreach($pro保险){{{$pro->name} @endforeach

试图获得财产';名称';非对象的定义?我用弹拨的时候 正在尝试获取非对象的属性“name”?当我使用pull()从数据库检索数据时 //a、 控制器 公共职能指数(){ $insurance=insurance_Providers::pull('id','name'); $medicines=medicines::pull('id','pp','sp'); $pharmacies=pharmacies::pull('id','name'); 返回视图('auth.profile',compact('insurance','medicines','pharmacies'); } //a、 blade.php 保险商 @foreach($pro保险){{{$pro->name} @endforeach,php,laravel-5,Php,Laravel 5,正在尝试获取非对象的属性“name”?当我使用Pull()从数据库检索数据时,您在Pull中使用了三个参数 Trying to get property 'name' of non-object? when i using pluck() for retrive data from database //a.contoller public function index(){ $insurance = Insurance_Providers::pl

正在尝试获取非对象的属性“name”?当我使用Pull()从数据库检索数据时,您在Pull中使用了三个参数

     Trying to get property 'name' of non-object? when i using pluck() for retrive data from database

//a.contoller       
     public function index(){
      $insurance = Insurance_Providers::pluck('id','name');
      $physicians = Physicians::pluck('id','pp','sp');
      $pharmacies = Pharmacies::pluck('id','name');
      return view('auth.profile',compact('insurance','physicians','pharmacies'));
    }

//a.blade.php
    <select name="insurance" id="ip" class="form-control" required>
    <option value="">Insurance Provider</option>
     @foreach($insurance as $pro)   <option value="{{ $pro->name }}">{{ $pro->name }}</option>
     @endforeach
     </select>
在这个过程中

$insurance = Insurance_Providers::pluck('name', 'id'); // name is value and id is key
@foreach($pro保险)
{{$pro}}
@endforeach
它应该会起作用

第一个参数是值,第二个是键

@foreach($insurance as $pro)   
    <option value="{{ $pro }}">{{ $pro }}</option>
@endforeach