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


PHP IP::save方法代碼示例

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


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

示例1: submitNewAsset

 public function submitNewAsset()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
         $input = Input::all();
         //$warranty_start = $input["warranty_start"]!=null ? $input["warranty_start"] : "1994-04-16";
         //$notes = Input::get("notes")!=null ? trim(Input::get("notes")) : "";
         $typeChecker;
         if ($input["ip_type"] == "IPv4") {
             $typeChecker = $input["ipv4"];
         } else {
             $typeChecker = $input["ipv6"];
         }
         $validator = Validator::make(array("ip" => $typeChecker, "ip_type" => $input["ip_type"], "subnet" => trim($input["subnet"]), "employee_number" => $input["employee_number"]), array("ip" => "required|unique:tbl_ip_assets,ip", "ip_type" => "required", "subnet" => "required", "employee_number" => "required|exists:tbl_employees,employee_number"));
         if ($validator->fails()) {
             Input::flash();
             return Redirect::to('assets/IP/add/')->with('message', $validator->messages()->first());
         } else {
             //Create the asset
             $IP = new IP();
             $IP->ip = $typeChecker;
             $IP->ip_type = trim($input["ip_type"]);
             $IP->subnet = trim($input["subnet"]);
             $IP->requestor = trim($input["employee_number"]);
             //$team = Employee::where('employee_number','=', $req);
             //var_dump($IP->ip);
             //$IP->team = trim($team->unit_id);
             $IP->notes = trim($input["notes"]);
             $IP->save();
             //Log the new asset to asset logs
             if (!empty(trim($input["employee_number"]))) {
                 $employee = Employee::where("employee_number", "=", Input::get("employee_number"))->first();
                 $desc = "IP Asset <strong>" . $IP->ip . "</strong> added to the database and assigned to employee <strong>" . $employee->first_name . " " . $employee->last_name;
             } else {
                 $desc = "IP Asset <strong>" . $IP->ip . "</strong> added to the database";
             }
             $IPLog = new IPLog();
             $IPLog->user_id = Session::get("user_id");
             $IPLog->ip_id = $IP->id;
             $IPLog->employee_id = !empty($IP->employee->id) ? $IP->employee->id : null;
             $IPLog->description = $desc;
             $IPLog->transaction = "History";
             $IPLog->save();
             //Parallel logging to system logs
             $desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> added IP asset <strong>" . $IP->ip . "</strong>.";
             $newLog = new UserLog();
             $newLog->description = $desc;
             $newLog->user_id = Session::get('user_id');
             $newLog->type = "System";
             $newLog->save();
             return Redirect::to('assets/IP/add')->with('success', "You have successfully added a new IP asset.");
         }
     } else {
         return Redirect::to("/");
     }
 }
開發者ID:johndavedecena,項目名稱:vault,代碼行數:55,代碼來源:IPController.php


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