当前位置: 首页>>代码示例>>PHP>>正文


PHP Address::getAddressByCompanyId方法代码示例

本文整理汇总了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;
 }
开发者ID:kamitori,项目名称:khuongnhi2,代码行数:48,代码来源:CompaniesController.php


注:本文中的app\Address::getAddressByCompanyId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。