当前位置: 首页>>代码示例>>PHP>>正文


PHP Software::where方法代码示例

本文整理汇总了PHP中Software::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::where方法的具体用法?PHP Software::where怎么用?PHP Software::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Software的用法示例。


在下文中一共展示了Software::where方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submitAssetUpdate

 public function submitAssetUpdate()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
         $input = Input::all();
         $software = Software::find($input["id"]);
         if (!$software) {
             return Redirect::to("assets/software");
         }
         if (Session::get("user_type") != "Root" && $software->status == "Lost") {
             return Redirect::to("assets/software/update/" . $software->id);
         }
         if ($input["action"] == "") {
             return Redirect::to('assets/software/update/' . $input["id"])->with('message', "Please select an action to commit.");
         } else {
             if ($input["action"] == "transfer") {
                 return Redirect::to("assets/software/transferasset/" . $input["id"]);
             } else {
                 if ($input["action"] == "lost") {
                     return Redirect::to("assets/software/lostasset/" . $input["id"]);
                 }
             }
         }
         if (Session::has("secure")) {
             $product_key = trim($input["product_key"] != null) ? trim($input["product_key"]) : null;
         }
         $warranty_start = $input["warranty_start"] != null ? $input["warranty_start"] : "1994-04-16";
         $notes = Input::get("notes") != null ? trim(Input::get("notes")) : "";
         $validator = Validator::make(array("software asset tag" => $input["asset_tag"], "laptop" => $input["serial_number"], "software type" => $input["software_type"], "warranty start date" => $input["warranty_start"], "warranty end date" => $input["warranty_end"], "status" => $input["asset_status"]), array("software asset tag" => "required", "laptop" => "exists:tbl_assets,serial_number", "software type" => "required|exists:tbl_software_types,id", "warranty start date" => "required_with:warranty end date|date:Y-m-d", "warranty end date" => "date:Y-m-d|after:" . $warranty_start, "status" => "required|in:Available,PWU,Retired,Test Case"));
         if ($validator->fails()) {
             Input::flash();
             return Redirect::to('assets/software/update/' . $input["id"])->with('message', $validator->messages()->first());
         } else {
             if ($software->asset_tag != $input["asset_tag"] && (Software::where("asset_tag", "=", $input["asset_tag"])->first() || Asset::where("asset_tag", "=", $input["asset_tag"])->first())) {
                 Input::flash();
                 return Redirect::to('assets/software/update/' . $input["id"])->with('message', "Asset tag already exists in the database. This field should be unique.");
             } else {
                 if (Session::has("secure") && Session::get("user_type") == "Root" && empty(trim($input["product_key"]))) {
                     Input::flash();
                     return Redirect::to('assets/software/update/' . $input["id"])->with('message', "Product key is required.");
                 } else {
                     if (!empty(trim($input["serial_number"])) && !Asset::where("serial_number", "=", $input["serial_number"])->whereHas("classification", function ($q) {
                         $q->where("name", "=", "Laptops");
                     })->first()) {
                         Input::flash();
                         return Redirect::to('assets/software/update/' . $input["id"])->with('message', "Cannot assign software asset to non-laptop assets. Please check the serial number and try again.");
                     } else {
                         //These variables are used to track if anything has been changed.
                         $isChanged = false;
                         //Boolean variable that checks if anything has been changed. Changes to true when a change has been detected.
                         $changes = array();
                         //Collects the names of the columns that have been changed.
                         $index = 0;
                         //Provides the index number of $changes array.
                         if ($input["asset_tag"] != $software->asset_tag) {
                             // 					$oldAssetTag = !empty($software->asset_tag) ? $software->asset_tag : "none";
                             // 					$newAssetTag = !empty(trim($input["asset_tag"])) ? trim($input["asset_tag"]) : "none";
                             $isChanged = true;
                             $changes[$index] = 1 + $index . ".) asset tag (from <strong>" . $software->asset_tag . "</strong> to <strong>" . trim($input["asset_tag"]) . "</strong>)<br/>";
                             $index += 1;
                         }
                         if (Session::has("secure") && Session::get("user_type") == "Root" && $input["product_key"] != $software->product_key) {
                             $isChanged = true;
                             //$changes[$index] = 1+$index.".) product key (from <strong>".$software->product_key."</strong> to <strong>".$input["product_key"]."</strong>)<br/>";
                             $changes[$index] = 1 + $index . ".) product key (changes have been hidden).<br/>";
                             $index += 1;
                         }
                         if ($input["serial_number"] != $software->assigned_to_serial_number) {
                             $isChanged = true;
                             $changes[$index] = 1 + $index . ".) laptop assignment (from <strong>" . $software->assigned_to_serial_number . "</strong> to <strong>" . $input["serial_number"] . "</strong>)<br/>";
                             $index += 1;
                         }
                         if ($input["location"] != $software->location) {
                             $newLocation = $input["location"];
                             $newLocation = empty(trim($newLocation)) ? "none" : $newLocation;
                             $oldLocation = empty($software->location) ? "none" : $software->location;
                             $isChanged = true;
                             $changes[$index] = 1 + $index . ".) location (from <strong>" . $oldLocation . "</strong> to <strong>" . $newLocation . "</strong>)<br/>";
                             $index += 1;
                         }
                         if ($input["software_type"] != $software->software_type_id) {
                             $newSoftwareType = SoftwareType::find($input["software_type"]);
                             $isChanged = true;
                             $changes[$index] = 1 + $index . ".) software type (from <strong>" . $software->type->software_type . "</strong> to <strong>" . $newSoftwareType->software_type . "</strong>)<br/>";
                             $index += 1;
                         }
                         if ($input["warranty_start"] != $software->warranty_start) {
                             $oldWarrantyStart = !empty($software->warranty_start) ? $software->warranty_start : "none";
                             $newWarrantyStart = !empty(trim($input["warranty_start"])) ? trim($input["warranty_start"]) : "none";
                             $isChanged = true;
                             $changes[$index] = 1 + $index . ".) warranty start date (from <strong>" . $oldWarrantyStart . "</strong> to <strong>" . $newWarrantyStart . "</strong>)<br/>";
                             $index += 1;
                         }
                         if ($input["warranty_end"] != $software->warranty_end) {
                             $oldWarrantyEnd = !empty($software->warranty_end) ? $software->warranty_end : "none";
                             $newWarrantyEnd = !empty(trim($input["warranty_end"])) ? trim($input["warranty_end"]) : "none";
                             $isChanged = true;
                             $changes[$index] = 1 + $index . ".) warranty end date (from <strong>" . $oldWarrantyEnd . "</strong> to <strong>" . $newWarrantyEnd . "</strong>)<br/>";
                             $index += 1;
                         }
                         if ($input["asset_status"] != $software->status) {
//.........这里部分代码省略.........
开发者ID:johndavedecena,项目名称:vault,代码行数:101,代码来源:SoftwareController.php

示例2: softwareAssetsReports

 public function softwareAssetsReports()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin" || Session::get("user_type") == "User")) {
         $view = View::make("Reports.software_assets_reports");
         $view->nav = "system";
         $view->tab = "software";
         $totalSoftwareAssets = Software::all()->count();
         $softwareTypes = SoftwareType::orderBy("software_type")->get();
         $available = Software::where("status", "=", "Available")->count();
         $pwu = Software::where("status", "=", "PWU")->count();
         $retired = Software::where("status", "=", "Retired")->count();
         $test_case = Software::where("status", "=", "Test Case")->count();
         $lost = Software::where("status", "=", "Lost")->count();
         $view->softwareTypes = $softwareTypes;
         $view->available = $available;
         $view->pwu = $pwu;
         $view->retired = $retired;
         $view->test_case = $test_case;
         $view->lost = $lost;
         $view->totalSoftwareAssets = $totalSoftwareAssets;
         return $view;
     } else {
         return Redirect::to("/");
     }
 }
开发者ID:johndavedecena,项目名称:vault,代码行数:25,代码来源:ReportsController.php

示例3: exportSoftwareBegin

 public function exportSoftwareBegin()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
         if (isset($_GET["search"])) {
             $view = View::make("Export.export_software");
             $view->nav = "system";
             $view->tab = "software";
             $input = Input::all();
             $asset_tag = trim($input["asset_tag"]) != null ? str_replace(' ', '%', trim($input["asset_tag"])) : "";
             $employee = trim($input["employee"]) != null ? trim($input["employee"]) : "";
             $serial_number = trim($input["serial_number"]) != null ? str_replace(' ', '%', trim($input["serial_number"])) : "";
             $software_type = trim($input["software_type"]) != null ? str_replace(' ', '%', trim($input["software_type"])) : "";
             $asset_status = !empty($input["asset_status"]) ? $input["asset_status"] : "";
             $warranty_start = trim($input["warranty_start"]) != null ? str_replace(' ', '%', trim($input["warranty_start"])) : "";
             $warranty_end = trim($input["warranty_end"]) != null ? str_replace(' ', '%', trim($input["warranty_end"])) : "";
             $software = Software::where("asset_tag", "LIKE", "%{$asset_tag}%")->where(function ($query) use($employee) {
                 $emp = "%" . str_replace(' ', '%', $employee) . "%";
                 $emp = DB::connection()->getPdo()->quote($emp);
                 if (!empty($employee)) {
                     $query->where("employee_number", "LIKE", $employee)->orWhereHas("employee", function ($q) use($employee, $emp) {
                         $q->whereRaw("concat(first_name,' ',last_name) LIKE {$emp}");
                     })->orWhereHas("employee", function ($q) use($employee, $emp) {
                         $q->whereRaw("concat(last_name,' ',first_name) LIKE {$emp}");
                     });
                 }
             })->where(function ($query) use($serial_number) {
                 if (!empty($serial_number)) {
                     $query->where("assigned_to_serial_number", "=", $serial_number);
                 }
             })->where(function ($query) use($software_type) {
                 if (!empty(${$software_type})) {
                     $query->where("software_type_id", "=", $software_type);
                 }
             })->where(function ($query) use($asset_status) {
                 if (!empty($asset_status)) {
                     $query->where("status", "=", $asset_status);
                 }
             })->where(function ($query) use($warranty_start) {
                 if (!empty($warranty_start)) {
                     $query->where("warranty_start", "LIKE", "{$warranty_start}%");
                 }
             })->where(function ($query) use($warranty_end) {
                 if (!empty($warranty_end)) {
                     $query->where("warranty_end", "LIKE", "{$warranty_end}%");
                 }
             })->orderBy("asset_tag")->paginate(25);
             $result = Software::where("asset_tag", "LIKE", "%{$asset_tag}%")->where(function ($query) use($employee) {
                 $emp = "%" . str_replace(' ', '%', $employee) . "%";
                 $emp = DB::connection()->getPdo()->quote($emp);
                 if (!empty($employee)) {
                     $query->where("employee_number", "LIKE", $employee)->orWhereHas("employee", function ($q) use($employee, $emp) {
                         $q->whereRaw("concat(first_name,' ',last_name) LIKE {$emp}");
                     })->orWhereHas("employee", function ($q) use($employee, $emp) {
                         $q->whereRaw("concat(last_name,' ',first_name) LIKE {$emp}");
                     });
                 }
             })->where(function ($query) use($serial_number) {
                 if (!empty($serial_number)) {
                     $query->where("assigned_to_serial_number", "=", $serial_number);
                 }
             })->where(function ($query) use($software_type) {
                 if (!empty(${$software_type})) {
                     $query->where("software_type_id", "=", $software_type);
                 }
             })->where(function ($query) use($asset_status) {
                 if (!empty($asset_status)) {
                     $query->where("status", "=", $asset_status);
                 }
             })->where(function ($query) use($warranty_start) {
                 if (!empty($warranty_start)) {
                     $query->where("warranty_start", "LIKE", "{$warranty_start}%");
                 }
             })->where(function ($query) use($warranty_end) {
                 if (!empty($warranty_end)) {
                     $query->where("warranty_end", "LIKE", "{$warranty_end}%");
                 }
             })->count();
             $getSoftwareTypes = SoftwareType::all();
             $softwareTypes = array("" => "--Select One--");
             foreach ($getSoftwareTypes as $gst) {
                 $softwareTypes[$gst->id] = $gst->software_type;
             }
             $view->softwareTypes = $softwareTypes;
             $view->software = $software;
             $view->results = $result;
             Input::flash();
             return $view;
         } else {
             if (isset($_GET["export"])) {
                 $input = Input::all();
                 $asset_tag = trim($input["asset_tag"]) != null ? str_replace(' ', '%', trim($input["asset_tag"])) : "";
                 $employee = trim($input["employee"]) != null ? trim($input["employee"]) : "";
                 $serial_number = trim($input["serial_number"]) != null ? str_replace(' ', '%', trim($input["serial_number"])) : "";
                 $software_type = trim($input["software_type"]) != null ? str_replace(' ', '%', trim($input["software_type"])) : "";
                 $asset_status = !empty($input["asset_status"]) ? $input["asset_status"] : "";
                 $warranty_start = trim($input["warranty_start"]) != null ? str_replace(' ', '%', trim($input["warranty_start"])) : "";
                 $warranty_end = trim($input["warranty_end"]) != null ? str_replace(' ', '%', trim($input["warranty_end"])) : "";
                 if (Session::has("secure") && Session::get("user_type") == "Root" && isset($_GET["pk"])) {
                     $software = Software::where("asset_tag", "LIKE", "%{$asset_tag}%")->where(function ($query) use($employee) {
                         $emp = "%" . str_replace(' ', '%', $employee) . "%";
//.........这里部分代码省略.........
开发者ID:johndavedecena,项目名称:vault,代码行数:101,代码来源:ExportController.php


注:本文中的Software::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。