本文整理汇总了PHP中Combination::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Combination::with方法的具体用法?PHP Combination::with怎么用?PHP Combination::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Combination
的用法示例。
在下文中一共展示了Combination::with方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}