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


PHP Company::All方法代码示例

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


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

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $filename = $this->argument('filename');
     if (!$this->option('web-importer')) {
         $logFile = $this->option('logfile');
         \Log::useFiles($logFile);
         if ($this->option('testrun')) {
             $this->comment('====== TEST ONLY Asset Import for ' . $filename . ' ====');
             $this->comment('============== NO DATA WILL BE WRITTEN ==============');
         } else {
             $this->comment('======= Importing Assets from ' . $filename . ' =========');
         }
     }
     if (!ini_get("auto_detect_line_endings")) {
         ini_set("auto_detect_line_endings", '1');
     }
     $csv = Reader::createFromPath($this->argument('filename'));
     $csv->setNewline("\r\n");
     $results = $csv->fetchAssoc();
     $newarray = null;
     foreach ($results as $index => $arraytoNormalize) {
         $internalnewarray = array_change_key_case($arraytoNormalize);
         $newarray[$index] = $internalnewarray;
     }
     $this->locations = Location::All(['name', 'id']);
     $this->categories = Category::All(['name', 'category_type', 'id']);
     $this->manufacturers = Manufacturer::All(['name', 'id']);
     $this->asset_models = AssetModel::All(['name', 'modelno', 'category_id', 'manufacturer_id', 'id']);
     $this->companies = Company::All(['name', 'id']);
     $this->status_labels = Statuslabel::All(['name', 'id']);
     $this->suppliers = Supplier::All(['name', 'id']);
     $this->assets = Asset::all(['asset_tag']);
     $this->accessories = Accessory::All(['name']);
     $this->consumables = Consumable::All(['name']);
     $this->customfields = CustomField::All(['name']);
     $bar = null;
     if (!$this->option('web-importer')) {
         $bar = $this->output->createProgressBar(count($newarray));
     }
     // Loop through the records
     DB::transaction(function () use(&$newarray, $bar) {
         Model::unguard();
         $item_type = strtolower($this->option('item-type'));
         foreach ($newarray as $row) {
             // Let's just map some of these entries to more user friendly words
             // Fetch general items here, fetch item type specific items in respective methods
             /** @var Asset, License, Accessory, or Consumable $item_type */
             $item_category = $this->array_smart_fetch($row, "category");
             $item_company_name = $this->array_smart_fetch($row, "company");
             $item_location = $this->array_smart_fetch($row, "location");
             $item_status_name = $this->array_smart_fetch($row, "status");
             $item["item_name"] = $this->array_smart_fetch($row, "item name");
             if ($this->array_smart_fetch($row, "purchase date") != '') {
                 $item["purchase_date"] = date("Y-m-d 00:00:01", strtotime($this->array_smart_fetch($row, "purchase date")));
             } else {
                 $item["purchase_date"] = null;
             }
             $item["purchase_cost"] = $this->array_smart_fetch($row, "purchase cost");
             $item["order_number"] = $this->array_smart_fetch($row, "order number");
             $item["notes"] = $this->array_smart_fetch($row, "notes");
             $item["quantity"] = $this->array_smart_fetch($row, "quantity");
             $item["requestable"] = $this->array_smart_fetch($row, "requestable");
             $item["asset_tag"] = $this->array_smart_fetch($row, "asset tag");
             $this->current_assetId = $item["item_name"];
             if ($item["asset_tag"] != '') {
                 $this->current_assetId = $item["asset_tag"];
             }
             $this->log('Category: ' . $item_category);
             $this->log('Location: ' . $item_location);
             $this->log('Purchase Date: ' . $item["purchase_date"]);
             $this->log('Purchase Cost: ' . $item["purchase_cost"]);
             $this->log('Company Name: ' . $item_company_name);
             $this->log('Status: ' . $item_status_name);
             $item["user"] = $this->createOrFetchUser($row);
             $item["location"] = $this->createOrFetchLocation($item_location);
             $item["category"] = $this->createOrFetchCategory($item_category, $item_type);
             $item["manufacturer"] = $this->createOrFetchManufacturer($row);
             $item["company"] = $this->createOrFetchCompany($item_company_name);
             $item["status_label"] = $this->createOrFetchStatusLabel($item_status_name);
             switch ($item_type) {
                 case "asset":
                     // -----------------------------
                     // CUSTOM FIELDS
                     // -----------------------------
                     // Loop through custom fields in the database and see if we have any matches in the CSV
                     foreach ($this->customfields as $customfield) {
                         if ($item['custom_fields'][$customfield->db_column_name()] = $this->array_smart_custom_field_fetch($row, $customfield)) {
                             $this->log('Custom Field ' . $customfield->name . ': ' . $this->array_smart_custom_field_fetch($row, $customfield));
                         }
                     }
                     $this->createAssetIfNotExists($row, $item);
                     break;
                 case "accessory":
                     $this->createAccessoryIfNotExists($item);
                     break;
//.........这里部分代码省略.........
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:101,代码来源:ObjectImportCommand.php


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