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


PHP Helper::ParseFloat方法代码示例

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


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

示例1: createConsumableIfNotExists

 /**
  * Create a consumable if a duplicate does not exist
  *
  * @author Daniel Melzter
  * @since 3.0
  * @param $item array
  */
 public function createConsumableIfNotExists(array $item)
 {
     $consumable = null;
     $editingConsumable = false;
     $this->log("Creating Consumable");
     foreach ($this->consumables as $tempconsumable) {
         if (strcasecmp($tempconsumable->name, $item["item_name"]) == 0) {
             $this->log("A matching consumable " . $item["item_name"] . " already exists");
             if (!$this->option('update')) {
                 $this->log("Skipping consumable.");
                 return;
             }
             $this->log('Updating matching consumable with new values');
             $editingConsumable = true;
             $consumable = $tempconsumable;
         }
     }
     if (is_null($consumable)) {
         $this->log("No matching consumable, creating one");
         $consumable = new Consumable();
     }
     if (!$editingConsumable) {
         $consumable->name = $item["item_name"];
     }
     if (!empty($item["purchase_date"])) {
         $consumable->purchase_date = $item["purchase_date"];
     } else {
         $consumable->purchase_date = null;
     }
     if (!empty($item["purchase_cost"])) {
         $consumable->purchase_cost = Helper::ParseFloat($item["purchase_cost"]);
     }
     if ($item["location"]) {
         $consumable->location_id = $item["location"]->id;
     }
     $consumable->user_id = $this->option('user_id');
     if ($item["company"]) {
         $consumable->company_id = $item["company"]->id;
     }
     if (!empty($item["order_number"])) {
         $consumable->order_number = $item["order_number"];
     }
     if ($item["category"]) {
         $consumable->category_id = $item["category"]->id;
     }
     // TODO:Implement
     //$consumable->notes= e($item_notes);
     if (!empty($item["requestable"])) {
         $consumable->requestable = filter_var($item["requestable"], FILTER_VALIDATE_BOOLEAN);
     }
     if (!empty($item["quantity"])) {
         if ($item["quantity"] > -1) {
             $consumable->qty = $item["quantity"];
         } else {
             $consumable->qty = 1;
         }
     }
     if (!$this->option("testrun")) {
         // dd($consumable);
         if ($consumable->save()) {
             $this->log("Consumable " . $item["item_name"] . ' was created');
             // $this->comment("Consumable " . $item["item_name"] . ' was created');
         } else {
             $this->jsonError('Consumable', $consumable->getErrors());
         }
     } else {
         $this->log('TEST RUN - Consumable ' . $item['item_name'] . ' not created');
     }
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:76,代码来源:ObjectImportCommand.php


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