* User: Dmitriy Pivovarov aka AngryDeer http://studioweb.pro * Date: 20.12.15 * Time: 19:50 * * List markers from MarkerGroup by $groupid * $groupid must be argument in call * */ ?> <!--recipes search widget--> <div class="widget recipe-search"> <div class="category-list"> <ul> <?php $MarkerGroup = \App\MarkerGroup::find($groupid); ?> @foreach($MarkerGroup->markers as $marker) <li> <a href="{{ URL::to('/menu/' . $marker->id) }}">{{$marker->name}}</a> <div class="list-icons"> <img src="{{ URL::to('imgpref/' . $marker->ico . '/42/42' ) }}" alt=""> </div> </li> @endforeach </ul> </div> </div> <!--recipes search widget ends-->
/** * @param $idMarkerGroup * @return string name Marker belong to this post and MarkerGroup */ public function getMarkerNameByMarkerGroupId($idMarkerGroup) { $markersInThisRecipie = $this->markers; $markersGroup = MarkerGroup::find($idMarkerGroup); $markersInMarkerGroupById = $markersGroup->markers; $arrIdMarkersFromGroup = []; foreach ($markersInMarkerGroupById as $marker) { $arrIdMarkersFromGroup[] = $marker->id; } foreach ($markersInThisRecipie as $marker) { if (in_array($marker->id, $arrIdMarkersFromGroup)) { return $marker->name; } } return ""; }