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


PHP Protocol::whereName方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $algorithmsXmls = File::allFiles(public_path() . '/algorithms');
     foreach ($algorithmsXmls as $algorithmsXml) {
         $dom = new DomDocument();
         $dom->load($algorithmsXml);
         $root = $dom->documentElement;
         $modality = Modality::whereName($root->getAttribute('modality'))->first();
         if (empty($modality)) {
             throw new Exception("Could not find modality! ({$algorithmsXml})");
         }
         $protocolName = $root->getAttribute('protocol');
         $protocol = Protocol::whereName($protocolName)->whereModalityId($modality->Id)->first();
         if (empty($protocol)) {
             \Log::warning("Could not find protocol! ({$algorithmsXml})");
             continue;
         }
         $arguments = [];
         $parameters = [];
         $description = "";
         foreach ($root->childNodes as $node) {
             if (get_class($node) == 'DOMText') {
                 continue;
             }
             switch ($node->nodeName) {
                 case 'arguments':
                     foreach ($node->childNodes as $argument) {
                         if (get_class($argument) == 'DOMText') {
                             continue;
                         }
                         $arguments[] = ['Name' => $argument->getAttribute('name')];
                     }
                     break;
                 case 'parameters':
                     foreach ($node->childNodes as $parameter) {
                         if (get_class($parameter) == 'DOMText') {
                             continue;
                         }
                         $parameters[] = ['Name' => $parameter->getAttribute('name'), 'Type' => $parameter->getAttribute('type'), 'Value' => $parameter->hasAttribute('value') ? $parameter->getAttribute('value') : null];
                     }
                     break;
                 case 'description':
                     $description = $node->textContent;
                     break;
                 default:
                     throw new Exception("Unrecognized entry in algorithm XML - {$node->nodeName}! ({$algorithmsXml})");
             }
         }
         $algorithm = new Algorithm();
         $algorithm->content = $description;
         $resultName = $root->getAttribute('result');
         $resultType = $root->getAttribute('type');
         $result = Parameter::whereName($resultName)->first();
         if (empty($result)) {
             $result = Parameter::create(['Name' => $resultName, 'Type' => $resultType]);
         }
         $algorithm->result()->associate($result);
         $algorithm->protocol()->associate($protocol);
         $algorithm->save();
         foreach ($arguments as $argument) {
             $algorithm->arguments()->attach(Argument::create($argument));
         }
         foreach ($parameters as $parameter) {
             $algorithm->attribute($parameter);
         }
     }
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:73,代码来源:AlgorithmSeeder.php

示例2: makeSimulation

 public function makeSimulation($caption, $patient, $organ, $model, $protocol, $parameterData, $regionData, $needles)
 {
     $numerical_model = NumericalModel::whereName($model)->first();
     $protocol = Protocol::whereName($protocol)->whereModalityId($numerical_model->Modality_Id)->first();
     $context = Context::byNameFamily($organ, 'organ');
     $combinations = $numerical_model->Combinations()->whereProtocolId($protocol->Id)->where(Context::$idField, "=", $context->Id);
     $combination = $combinations->first();
     $simulation = Simulation::create(['Combination_Id' => $combination->Combination_Id, 'Patient_Id' => $patient->Id ?: '00000000-0000-0000-0000-000000000000', 'Caption' => 'Sample Simulation for ' . $caption, 'SegmentationType' => 0, 'Progress' => '0', 'State' => 0, 'Color' => 0, 'Active' => 0]);
     /*
         foreach ($regionData as $name => $locations)
         {
      $region = Region::whereName($name)->first();
      foreach ($locations as $location)
        $simulation->regions()->attach($region, ['Location' => $location]);
         }
     */
     $simulation->save();
     $simulationNeedles = [];
     $needleData = [];
     $needleUserParameters = new Collection();
     $n = 0;
     foreach ($needles as $needleConfig) {
         $n++;
         $needle = Needle::whereManufacturer($needleConfig["Manufacturer"])->whereName($needleConfig["Name"])->first();
         $needleUserParameters[$needle->Id] = new Collection();
         $simulationNeedle = SimulationNeedle::create(['Needle_Id' => $needle->Id, 'Simulation_Id' => $simulation->Id, 'Target_Id' => $this->makePointSet($needleConfig["Parameters"]["NEEDLE_TIP_LOCATION"])->Id, 'Entry_Id' => $this->makePointSet($needleConfig["Parameters"]["NEEDLE_ENTRY_LOCATION"])->Id]);
         $simulationNeedleId = $simulationNeedle->Id;
         foreach ($needleConfig["Parameters"] as $paramName => $paramValue) {
             $parameter = Parameter::whereName($paramName)->first();
             $parameter->Value = $paramValue;
             $needleUserParameters[$needle->Id][$paramName] = $parameter;
         }
         $simulationNeedles[] = $needle;
     }
     $parameters = new Collection();
     foreach ($parameterData as $parameterName => $value) {
         $parameter = Parameter::whereName($parameterName)->first();
         $parameter->Value = $value;
         $parameters[$parameter->Name] = $parameter;
     }
     $incompatibilities = [];
     $userRequiredParameters = [];
     list($parameters, $needleParameters) = $combination->compileParameters($parameters, $simulationNeedles, $needleUserParameters, $incompatibilities, $userRequiredParameters);
     if (count($incompatibilities)) {
         var_dump($incompatibilities);
         var_dump($userRequiredParameters);
     }
     foreach ($parameters as $parameterName => $parameter) {
         $simulation->Parameters()->attach($parameter, ['ValueSet' => $parameter->Value]);
     }
     $simulation->SimulationNeedles->each(function ($simulationNeedle) use($needleParameters) {
         if (array_key_exists($simulationNeedle->Needle_Id, $needleParameters)) {
             $needleParameters[$simulationNeedle->Needle_Id]->each(function ($p) use($simulationNeedle) {
                 $simulationNeedle->Parameters()->attach($p);
             });
         }
     });
     $this->r++;
     print "Simulation #{$this->r}: " . $simulation->Combination->asString . " [ " . strtoupper($simulation->Id) . " ]\n";
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:60,代码来源:SimulationSeeder.php


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