本文整理汇总了PHP中app\Address::getAddressByCompanyId方法的典型用法代码示例。如果您正苦于以下问题:PHP Address::getAddressByCompanyId方法的具体用法?PHP Address::getAddressByCompanyId怎么用?PHP Address::getAddressByCompanyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Address
的用法示例。
在下文中一共展示了Address::getAddressByCompanyId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: anyUpdate
public function anyUpdate(Request $request)
{
$arr_return = array('status' => 'error');
$id = session('current_company') !== null ? session('current_company') : 0;
$address_id = session('current_address') !== null ? session('current_address') : 0;
if ($id) {
$company = Company::find($id);
$address = Address::getAddressByCompanyId($id);
session(['current_company' => $company['id'], 'current_address' => $address['id']]);
} else {
$company = Company::get()->last();
//$address = Address::get()->last();
if ($company && $address) {
session(['current_company' => $company->id, 'current_address' => $address->id]);
} else {
$company = new Company();
$company->save();
$address = new Address();
$address->save();
session(['current_company' => $company->id, 'current_address' => $address->id]);
}
}
$company->name = $request->has('name') ? $request->input('name') : '';
$company->phone = $request->has('phone') ? $request->input('phone') : '';
$company->company_type_id = $request->has('company_type') ? $request->input('company_type') : 0;
$company->fax = $request->has('fax') ? $request->input('fax') : '';
$company->email = $request->has('email') ? $request->input('email') : '';
$company->web = $request->has('web') ? $request->input('web') : '';
$company->is_customer = $request->has('is_customer') ? 1 : 0;
$company->is_distribute = $request->has('is_distribute') ? 1 : 0;
$address->address = $request->has('address') ? $request->input('address') : '';
$address->town_city = $request->has('town_city') ? $request->input('town_city') : '';
$address->province_id = $request->has('province_id') ? $request->input('province_id') : 0;
$address->country_id = $request->has('country_id') ? $request->input('country_id') : 0;
if ($company->save()) {
$arr_return['status'] = 'success';
$arr_return['name'] = $company->name;
} else {
$arr_return['message'] = 'Saving fail';
}
if ($address->save()) {
$arr_return['status'] = 'success';
$arr_return['name'] = $address->name;
} else {
$arr_return['message'] = 'Saving fail';
}
return $arr_return;
}