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


PHP Protocol::find方法代码示例

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


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

示例1: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $protocol = Protocol::find($id);
     if (empty($protocol)) {
         return Redirect::route('protocol.index')->withError("Protocol not found");
     }
     $protocol->combinations->load('PowerGenerator', 'NumericalModel');
     return View::make('protocols.show', compact('protocol'));
     //
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:16,代码来源:ProtocolController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $combinations = Combination::with('PowerGenerator');
     if (Input::has('Needle_Id')) {
         $combinations = $combinations->join('Combination_Needle', 'Combination_Needle.Combination_Id', '=', 'Combination.Combination_Id');
         $combinations->whereNeedleId(Input::get('Needle_Id'));
     }
     if (Input::has('Numerical_Model_Id')) {
         $combinations->whereNumericalModelId(Input::get('Numerical_Model_Id'));
     }
     if (Input::has('Power_Generator_Id')) {
         $combinations->wherePowerGeneratorId(Input::get('Power_Generator_Id'));
     }
     if (Input::has('Protocol_Id')) {
         $combinations->whereProtocolId(Input::get('Protocol_Id'));
     }
     if (Input::has('Context_Id')) {
         if (Config::get('gosmart.context_as_enum')) {
             $combinations->where(Context::$idField, '=', Input::get('Context_Id'));
         } else {
             $combinations->whereContextId(Input::get('Context_Id'));
         }
     }
     if (Input::has('Modality_Id')) {
         $modality_id = Input::get('Modality_Id');
         $combinations->whereHas('PowerGenerator', function ($query) use($modality_id) {
             $query->whereModalityId($modality_id);
         });
     }
     if (Input::has('output')) {
         switch (Input::get('output')) {
             case 'Needle':
                 $combination = $combinations->join('Combination_Needle', 'Combination_Needle.Combination_Id', '=', 'Combination.Combination_Id');
                 $output_ids = array_unique($combinations->get()->lists('Needle_Id'));
                 return Needle::find($output_ids)->lists('Name', 'Id');
             case 'Combination':
                 return $combinations->get()->lists('asString', 'Combination_Id');
             case 'Protocol':
                 $output_ids = array_unique($combinations->get()->lists('Protocol_Id'));
                 return Protocol::find($output_ids)->lists('Name', 'Id');
             case 'PowerGenerator':
                 $output_ids = array_unique($combinations->get()->lists('Power_Generator_Id'));
                 return PowerGenerator::find($output_ids)->lists('Name', 'Id');
             case 'NumericalModel':
                 $output_ids = array_unique($combinations->get()->lists('Numerical_Model_Id'));
                 return NumericalModel::find($output_ids)->lists('Name', 'Id');
             case 'Context':
                 if (Config::get('gosmart.context_as_enum')) {
                     $output_ids = array_unique($combinations->get()->lists('Context_Id'));
                 } else {
                     $output_ids = array_unique($combinations->get()->lists('OrganType'));
                 }
                 return Context::find($output_ids)->lists('Name', 'Id');
             case 'Modality':
                 $combinations = $combinations->join('Power_Generator', 'Power_Generator.Id', '=', 'Combination.Power_Generator_Id')->select('Power_Generator.Modality_Id AS Modality_Id');
                 $output_ids = array_unique($combinations->get()->lists('Modality_Id'));
                 return Modality::find($output_ids)->lists('Name', 'Id');
         }
         return $combinations;
     }
     $combinations = $combinations->get()->sortBy(function ($c) {
         return $c->Power_Generator->Modality->Name;
     });
     return View::make('combinations.index', compact('combinations'));
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:70,代码来源:CombinationController.php


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