お世話になります。
Cakephp3系でfriendsofcakeを使用しているのですが、
日付の期間で検索が上手くできず質問させてください。
https://github.com/FriendsOfCake/search/issues/68
こちらにある通り、以下のように実装してみたのですが、うまくいきません。
View
PHP
1<?= $this->Form->input('start', [ 2 'class' => 'form-control calendar', 3 'label' => false, 4]); ?> 5 6<?= $this->Form->input('end', [ 7 'class' => 'form-control calendar', 8 'label' => false, 9]); ?>
Modelのinitialize内
PHP
1$this->addBehavior('Search.Search'); 2 $this->searchManager() 3 // ->value('date') 4 ->callback('start', [ 5 'callback' => function (Query $query, array $args) { 6 $query->where(function ($exp) use ($args) { 7 return $exp->between( 8 'Model.date', 9 $args['start'], 10 $args['end'] 11 ); 12 }); 13 } 14 ]);
つまづいているところは、
searchManagerで定義していないstartとendはModel内で取得することが出来ません。
ご存知の方、教えていただきたいです。
回答1件
あなたの回答
tips
プレビュー