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