ตารางเลขหน้าด้วยความสัมพันธ์ HasMany ใน cakephp 3 เบต้า

ฉันมีตารางโฆษณาที่มีช่อง (group_id,member_id,city_id) นี่คือวิธี GroupsController->view ของฉัน

public function view($id = null) {
    $group = $this->Groups->get($id);
    $this->paginate = ['conditions'=>['group_id'=>$id] , 'contain'=>['Members', 'Cities']];
    $advertisements = $this->paginate($this->Groups->Advertisements);
    $this->set(compact('group' , 'advertisements'));
}

มันสร้างคำเตือนนี้นอกเหนือจากผลลัพธ์ที่แท้จริง

Warning (4096): Argument 1 passed to Cake\Controller\Component\PaginatorComponent::validateSort() must be an instance of Cake\ORM\Table, instance of Cake\ORM\Association\HasMany given, called in D:\xampp\htdocs\project\vendor\cakephp\cakephp\src\Controller\Component\PaginatorComponent.php on line 153 and defined [CORE\src\Controller\Component\PaginatorComponent.php, line 301]

เกิดอะไรขึ้น?


person anghazi ghermezi    schedule 21.01.2015    source แหล่งที่มา


คำตอบ (1)


ตัวรับคุณสมบัติเวทย์มนตร์ ส่งคืนอินสแตนซ์ \Cake\ORM\Association หากคุณต้องการวัตถุ \Cake\ORM\Table จริง ให้ใช้ Association::target().

$this->Groups->Advertisements->target()
person ndm    schedule 21.01.2015