Laravel 当我点击编辑按钮时,给我一个错误

Laravel 当我点击编辑按钮时,给我一个错误,laravel,laravel-5,laravel-4,eloquent,laravel-5.2,Laravel,Laravel 5,Laravel 4,Eloquent,Laravel 5.2,当我点击编辑按钮,它给我一个错误,什么是问题,我现在不能理解,请帮助我 正在尝试获取非对象的属性“id”(视图:C:\xampp\htdocs\ytl\resources\views\profile\edit.blade.php) 这是我的userprofilecontroller public function edit( Request $request, $id){ $user_profile_id = UserProfile::where('id', '=', $id)-&g

当我点击编辑按钮,它给我一个错误,什么是问题,我现在不能理解,请帮助我

正在尝试获取非对象的属性“id”(视图:C:\xampp\htdocs\ytl\resources\views\profile\edit.blade.php)

这是我的userprofilecontroller

public function edit( Request $request, $id){

    $user_profile_id = UserProfile::where('id', '=', $id)->firstOrFail();

    $exchanges = Exchange::pluck('exchange','id')->all();
    $markets = Market::pluck('market','id')->all();
    $countries = Country::pluck('country','id')->all();
    $brokerage_company = BrokerageCompany::pluck ('brokerage_company','id')->all();
    $user_profile = UserProfile::pluck('charge_intraday','charge_delivery','charge_per_lot','charge_per_order')->all();



    return view('profile.edit', compact('user_profile_id','exchanges','markets','countries','brokerage_company','user_profile'));

}
public function update(Request $request, $id){

    $user_profile_id = UserProfile::findOrFail($id);
   $input = $request->except( 'brokerage_company','user_profile');
  $user_id = $user_profile->update($input);


    return redirect('/profile');

}
这是profile\index.blade.php文件

<div class="card card-table">
        <div class="card-header">Basic Tables
            <div class="tools dropdown"><span class="icon mdi mdi-download"></span><a class="dropdown-toggle" href="#" role="button" data-toggle="dropdown"><span class="icon mdi mdi-more-vert"></span></a>
                <div class="dropdown-menu" role="menu"><a class="dropdown-item" href="#">Action</a><a class="dropdown-item" href="#">Another action</a><a class="dropdown-item" href="#">Something else here</a>
                    <div class="dropdown-divider"></div><a class="dropdown-item" href="#">Separated link</a>
                </div>
            </div>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                <tr>
                    <th style="width:10%;">Country</th>
                    <th style="width:10%;">Exchange</th>
                    <th class="number">Market</th>
                    <th class="number">Company</th>
                    <th class="actions">Charges</th>
                </tr>
                </thead>
                @if($user_profile)
                    <tbody>
                    @foreach($user_profile   as $user_profiles)
                <tr>

                    <td>{{$user_profiles->country->country}}</td>
                    <td>{{$user_profiles->exchange->exchange}}</td>
                    <td>{{$user_profiles->market->market}}</td>
                    <td>{{$user_profiles->brokerage_company->brokerage_company}}</td>
                    <td class="cell-detail"><span>Intaday-charge</span>{{$user_profiles->charge_intraday}}
                        <span class="cell-detail-description">Delivery-charge</span>
                        {{$user_profiles->charge_delivery}}</td>
                    {{--<td>{{$user_profiles->charge_per_lot}}</td>--}}
                    {{--<td>{{$user_profiles->charge__per_order}} </td>--}}
                    <td> <a class="btn btn-info btn-sm" href="{{route('profile.edit', $user_profiles->id)}}">Edit</a></td>

                </tr>

                        @endforeach
                </tbody>
                    @endif
            </table>
        </div>
    </div>

基本表格
国家
交换
市场
单位
收费
@if($user\u profile)
@foreach($user\u profile作为$user\u profiles)
{{$user_profiles->country->country}
{{$user\u profiles->exchange->exchange}
{{$user_profiles->market->market}
{{$user\u profiles->brokerage\u company->brokerage\u company}
日内收费{{$user\u profiles->charge\u intraday}
送货费
{{$user\u profiles->charge\u delivery}
{{--{$user\u profiles->charge\u per\u lot}}--}
{{--{$user\u profiles->charge\u per\u order}}--}
@endforeach
@恩迪夫
这是profile\edit.blade.php文件


加价
&时代;
{{----}}
{{--{csrf_field()}}--}
{{--{{method_字段('PATCH')}}--}
{!!Form::model($user\u profile,['method'=>'PATCH','action'=>['profile\UserProfileController@update“,$user_profile->id]])
国家:
挑选
@foreach($key=>$val的国家)
{{$val->country}
@endforeach
交换:
挑选
{{--@foreach($key=>$val)交换--}
{{--{$val->exchange}--}}
{{--@endforeach--}
市场
挑选
{{--@foreach($key=>$val)市场--}
{{--{$val->market}}--}}
{{--@endforeach--}
公司:
挑选
@foreach($key=>val的经纪公司)
{{$val->经纪公司}
@endforeach
日内费用:
送货费:
送货费:
送货费:
{!!Form::close()!!} 接近 保存更改
您似乎误解了
pull
方法。Pulk是通过键从数组中取出几个属性。与从数据库中选择列无关

我想您需要选择一个
用户配置文件
。正确的做法如下:

public function edit(Request $request, $id){

    $user_profile = UserProfile::findOrFail($id); // Select a UserProfile by ID or fail

    $exchanges = Exchange::all('exchange', 'id'); 
    $markets = Market::all('market','id');
    $countries = Country::all('country','id');
    $brokerage_company = BrokerageCompany::all ('brokerage_company','id');
    // I dont know what you want with this statement?
    // $user_profile = UserProfile::pluck('charge_intraday','charge_delivery','charge_per_lot','charge_per_order')->all();

    return view('profile.edit', compact('user_profile','exchanges','markets','countries','brokerage_company'));

}

错误是关于访问
edit.blade.php中的
array
在问题中添加错误行否更新的问题@deepakpateludated this
{!!Form::model($user\u profile,['method'=>'PATCH',action'=>['profile\UserProfileController@update“,$user\u profile->id]])!!}
{!!表单::模型($user\u profile,['method'=>'PATCH','action'=>['Profile\UserProfileController@update“,$user_profile['id']]])!!
更新您的代码,它会给我错误“未定义的索引:id(视图:C:\xampp\htdocs\ytl\resources\views\profile\edit.blade.php)”-@DeepakPatel