0
필터를 만들고 있으므로 존재하지 않는 특성을 모델링에 추가 한 다음 필터링 테이블에 사용해야합니다. 어디서() 시도하지만 문제는 추가 된 특성을 찾을 수 없다는 것입니다. 여기에 예제 코드는 다음과 같습니다Laravel 추가 된 특성을 사용하는 ORM 필터링
<?php
class School extends Eloquent {
protected $table = 'schools';
protected $appends = array('municipality_id');
public function getMunicipalityIdAttribute()
{
return City::find($this->city_id)->municipality_id;
}
public function listSchoolsEndUser()
{
$schools_data = new School;
if (Input::has('municipality')) {
$schools_data = $schools_data->where('municipality_id', '=', Input::get('municipality'));
}
$schools_data = $schools_data->paginate(12);
return $schools_data;
}
}
오류 :
SQLSTATE[42S22]: Column not found: 1054 Unknown column municipality_id' in 'where clause' (SQL: select count(*) as aggregate from `schools` where (`specialties` like %"5"%) and `municipality_id` = 6)
내가 district_id 오류 메시지에서 그것으로 오는 방법을 잘 모르겠어요 - 그이 예에서는 municipality_id해야 하는가? – Apemantus
네, 그건 내 실수예요, 미안 해요. – mertindervish