2
저는 Laravel과 Eloquent 클래스를 사용하고 있습니다. 세 가지 모델이 있습니다.Laravel Eloquent : 아이템 모델 관계 계산
City.php :
public function itineraries() {
return $this->has_many('Itinerary', 'city_id');
}
Itinerary.php :
public function city()
return $this->belongs_to('City');
}
public function type()
{
return $this->belongs_to('Itinerarytype');
}
Itinerarytype.php :
public function itineraries()
{
return $this->has_many('Itinerary');
}
당신이 도시는 많은 일정을 가지고 있으며, 여행 일정이 속한 볼 수 있듯이 도시 및 여정 유형. itinerarytype 모델에는 많은 여정이 있습니다.
with()
방법을 사용하면 여정 유형으로 그룹화 된 여정을 계산할 수 있습니까?
$city = City::with(array('itineraries'))->where_slug($city_slug)->first();
이 그 총알과의 일정을 모두 가지고있는 도시를 가져옵니다 여기 예를 들어
는 내가 지금까지 가지고있는 것입니다.
내가 좋아하는 목록을 좀하고 싶습니다 (텍스트는 일정 유형 및 수는 계산입니다)
History: 10 Entertainment: 5 Outdoor: 6 ...
방금이 중 하나를 삭제하십시오 : area51.stackexchange.com/proposals/46607/laravel;) – Kriem