本文整理汇总了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());
}