을 찾을 나는 Item
모델 belongsTo
Category
, ERGO Category
hasMany
Item
을 얻었다.CakePHP의이 hasMany의 관련 모델
에서 CategoriesController
을 모두 내고 싶습니다. 카테고리는 Item
입니다.
$category = $this->Category->findById($id);
:
if($id == null) {
throw new NotFoundException(__('404'));
}
$this->Category->id = $id;
if(!$this->Category->exists()) {
throw new NotFoundException(__('404'));
}
$items = $this->Category->Item->find();
$this->set('items',$items);