首页 > 解决方案 > Symfony\Component\Debug\Exception\FatalThrowableError (E_ERROR) 在 null 上调用成员函数 update()

问题描述

我想从同一个视图或一次更新两个表中的数据

public function edit($company_id)
{
    //dd($company);

    $company=company::findOrFail($company_id);
    $industry=Industry::get();
    $country=Country::where('country_name','India')->first();
    $state=State::where('country_id',$country->country_id)->get();
    $city=City::where('state_id',$company->company_state)->get();
    $segment=Segment::get();
    $HeadOffice=HeadOffice::get();
    //$CompanyOtherInfo=CompanyOtherInfo::get();
    $CompanyOtherInfo=CompanyOtherInfo::where('company_other_infos.company_id',$company_id)->get();

    //dd($industry);
    //dd($HeadOffice);
    //dd($program_type);
    return view('backend.company.editCompany',compact('company','industry','state','city','segment','HeadOffice','CompanyOtherInfo'));
}

public function update(Request $request, Company $company) 
{
    //dd($request->all());
    $company->update($request->all());
    $company->companyOtherInfo->update($request->all());

    return redirect('company/view');
}

标签: laravel-5

解决方案


推荐阅读