当前位置: 首页>>代码示例>>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;未经允许,请勿转载。