如何在Cakephp3中的contain中添加条件。
这是我的代码:
$this->paginate = [
'contain' => ['Users', 'AssignDrivers.Users', 'Invoices']
];
$bookings = $this->paginate($this->Bookings);
$this->set(compact('bookings'));
$this->set('_serialize', ['bookings']);
例如这样的东西:
$this->paginate($this->bookings)->where(['Bookings.status'=>'pending', 'AssignDrivers.name LIKE'=>'%John%']);
谢谢您的帮助。
答案 0 :(得分:0)
尝试在paginate()方法中使用条件。
$this->paginate = [
'contain' => ['Users', 'AssignDrivers.Users', 'Invoices']
];
$bookings = $this->paginate(
$this->Bookings->find()->where([
'Bookings.status'=>'pending',
'AssignDrivers.name LIKE'=>'%John%'
])
);
$this->set(compact('bookings'));
$this->set('_serialize', ['bookings']);