當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Branch::insertGetId方法代碼示例

本文整理匯總了PHP中Branch::insertGetId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Branch::insertGetId方法的具體用法?PHP Branch::insertGetId怎麽用?PHP Branch::insertGetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Branch的用法示例。


在下文中一共展示了Branch::insertGetId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: store

 public function store()
 {
     // Transaction strats here because we are connecting three tables
     \DB::beginTransaction();
     //User credintial information
     $username = \Input::get('branch_code');
     $password = str_random(10);
     $p_email = \Input::get('p_email');
     $s_contact_person = \Input::get('s_contact_person');
     $hashPassword = \Hash::make($password);
     //Insert user credentials
     $uId = \User::insertGetId(array('username' => $username, 'password' => $hashPassword, 'email' => $p_email, 'profilesId' => 2, 'active' => 'Y', 'displayname' => $s_contact_person));
     if (!$uId) {
         \DB::rollback();
         return \Redirect::back()->with('error', 'Failed to save');
     }
     $branch_name = \Input::get('branch_name');
     $branch_code = \Input::get('branch_code');
     $branch_address = \Input::get('branch_address');
     $branch_city = \Input::get('branch_city');
     $branch_state = \Input::get('branch_state');
     $branch_pin = \Input::get('branch_pin');
     $branch_land_line = \Input::get('branch_land_line');
     $branch_alt_land_line = \Input::get('branch_alt_land_line');
     $branch_fax = \Input::get('branch_fax');
     // Insert Branch into table
     $branchId = \Branch::insertGetId(array('branch_name' => $branch_name, 'branch_code' => $branch_code, 'branch_address' => $branch_address, 'branch_city' => $branch_city, 'branch_state' => $branch_state, 'branch_pin' => $branch_pin, 'branch_land_line' => $branch_land_line, 'branch_alt_land_line' => $branch_alt_land_line, 'branch_fax' => $branch_fax, 'user_id' => $uId));
     if (!$branchId) {
         \DB::callback();
         return \Redirect::back()->with('error', 'Failed to save');
     }
     // Branch contact information
     $branch_head = \Input::get('branch_head');
     $p_mobile_no = \Input::get('p_mobile_no');
     $p_alt_mobile_no = \Input::get('p_alt_mobile_no');
     $p_email = \Input::get('p_email');
     $p_alt_email = \Input::get('p_alt_email');
     $s_mobile_no = \Input::get('s_mobile_no');
     $s_alt_mobile_no = \Input::get('s_alt_mobile_no');
     $s_email = \Input::get('s_email');
     $s_alt_email = \Input::get('s_alt_email');
     //Insert Data to contact table
     $contactId = \BranchContact::insertGetId(array('branch_head' => $branch_head, 'p_mobile_no' => $p_mobile_no, 'p_alt_mobile_no' => $p_alt_mobile_no, 'p_email' => $p_email, 'p_alt_email' => $p_alt_email, 's_contact_person' => $s_contact_person, 's_mobile_no' => $s_mobile_no, 's_alt_mobile_no' => $s_alt_mobile_no, 's_email' => $s_email, 's_alt_email' => $s_alt_email, 'user_id' => $uId, 'branch_id' => $branchId));
     if (!$contactId) {
         \DB::rollback();
         return \Redirect::back()->with('error', 'Failed to add');
     } elseif ($contactId) {
         \DB::commit();
         \Mail::send('emails.user_credential', array('name' => $s_contact_person, 'username' => $username, 'password' => $password), function ($message) use($p_email, $username) {
             $message->to($p_email, $username)->subject('User Credential');
         });
         return \Redirect::back()->with('success', 'Successfully added');
     }
     print_r(\Input::all());
 }
開發者ID:bhoopal10,項目名稱:PayrollOriginal,代碼行數:55,代碼來源:BranchController.php


注:本文中的Branch::insertGetId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。