现在,由于以下问题,我必须创建大量刀片模板。我正在为这个问题寻求创造性的解决方案。其中之一是执行“select as”查询,但Eloquent Model::with()不支持别名(据我所知)。
@foreach($products as $product)
@foreach($product->typeAs as $typeA) or @foreach($product->typeBs as $typeB)
// same html for both typeA and typeB
@endforeach
@endforeach发布于 2013-10-31 21:56:58
对于这两种情况,您可能希望使用@include并传递具有相同名称的变量的子视图:
@foreach($product->typeAs as $typeA)
@include('view.name', array('type'=> $typeA))
@endforeach
@foreach($product->typeBs as $typeB)
@include('view.name', array('type'=> $typeB))
@endforeach您也可以参考docs
https://stackoverflow.com/questions/19707934
复制相似问题