laravel-5 - 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');
}
解决方案
推荐阅读
- haskell - 如何从另一个具有排列的序列实例(模拟“任何顺序”)
- c - 通过双指针查看二维数组的元素以进行调试
- c - 使用指针对整数求和的小程序
- haskell - 如何解决 Haskell 中不明确的类型变量错误
- vue.js - 单文件组件实例之间的共享数据
- javascript - 自动缩放元素以适应视口,当不是 100% 可见时
- android - 项目符号字符在 android 上过大
- javascript - 每次单击时如何增加框的宽度?
- cadence - Cadence Virtuoso Layout XL
- firebase-dynamic-links - 通过动态链接留住玩家(按月计算)