试图获得财产';名称';非对象的定义?我用弹拨的时候 正在尝试获取非对象的属性“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()从数据库检索数据时,您在Pull中使用了三个参数试图获得财产';名称';非对象的定义?我用弹拨的时候 正在尝试获取非对象的属性“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
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