本文整理汇总了PHP中Software::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::save方法的具体用法?PHP Software::save怎么用?PHP Software::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processImport
//.........这里部分代码省略.........
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("warranty start date")) {
foreach ($validator->messages()->get("warranty start date") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("warranty end date")) {
foreach ($validator->messages()->get("warranty end date") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
if ($validator->messages()->get("status")) {
foreach ($validator->messages()->get("status") as $e) {
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . $e . "<br/>";
}
}
}
if ($r->status != "Lost" && Employee::where("employee_number", "=", $r->employeenumber)->whereIn("status", array("OJT Graduate", "Graduate", "Resigned", "Obsolete"))->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign an asset to employees no longer working in the company." . "<br/>";
}
if (trim($r->laptopsn) != null && !Asset::where("serial_number", "=", $r->laptopsn)->whereHas("classification", function ($q) {
$q->where("name", "=", "Laptops");
})->first()) {
$hasError = true;
//This will only matter if no errors has been found above.
$rowHasError = true;
//This will only matter if no errors has been found above.
$rowsWithErrors[$rowIndex] = $rowIndex;
//This will only matter if no errors has been found above.
$errorCount += 1;
$error[$rowIndex][$errorCount] = $errorCount . ". " . "Cannot assign software asset to non-laptop assets. Please check the serial number and try again." . "<br/>";
}
if (!$rowHasError) {
$hasCorrectRows = true;
$software_type_id = SoftwareType::where("software_type", "=", $r->softwaretype)->get(array("id"))->first();
//Create the asset
$software = new Software();
$software->asset_tag = trim($r->assettag) != null ? trim($r->assettag) : null;
$software->product_key = trim($r->productkey);
$software->employee_number = trim($r->employeenumber) != null ? trim($r->employeenumber) : null;
$software->assigned_to_serial_number = trim($r->laptopsn) != null ? trim($r->laptopsn) : null;
$software->location = trim($r->location) != null ? trim($r->location) : null;
$software->software_type_id = $software_type_id->id;
$software->warranty_start = trim($r->warrantystart);
$software->warranty_end = trim($r->warrantyend);
$software->status = trim($r->status);
$software->notes = trim($r->notes) != null ? trim($r->notes) : null;
$software->date_added = date("Y-m-d H:i:s");
$software->save();
//Log the new asset to asset logs
if (!empty(trim($r->employeenumber))) {
$employee = Employee::where("employee_number", "=", trim($r->employeenumber))->first();
$desc = "Software Asset <strong>" . $software->asset_tag . "</strong> added to the database and assigned to employee <strong>" . $employee->first_name . " " . $employee->last_name . "</strong> with asset status <strong>" . $software->status . "</strong>.";
} else {
$desc = "Software Asset <strong>" . $software->asset_tag . "</strong> added to the database with status <strong>" . $software->status . "</strong>.";
}
$softwareLog = new SoftwareLog();
$softwareLog->user_id = Session::get("user_id");
$softwareLog->software_id = $software->id;
$softwareLog->employee_id = !empty($software->employee->id) ? $software->employee->id : null;
$softwareLog->description = $desc;
$softwareLog->transaction = "History";
$softwareLog->save();
//Parallel logging to system logs
$desc = "(" . Session::get('user_type') . ") " . "<strong>" . Session::get('username') . "</strong> added software asset <strong>" . $software->asset_tag . "</strong>.";
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->type = "System";
$newLog->save();
}
}
File::delete($readFile);
if ($hasCorrectRows) {
//Log the changes made
$desc = "(" . Session::get("user_type") . ") <b>" . Session::get("username") . "</b> has imported data to software assets database. ";
$newLog = new UserLog();
$newLog->description = $desc;
$newLog->user_id = Session::get('user_id');
$newLog->type = "System";
$newLog->save();
}
return $this->importResult($hasError, $hasCorrectRows, $rowsWithErrors, $error);
}
} else {
return Redirect::to('/');
}
}