SystemNoticeDao.php 734 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace app\common\dao\system\notice;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\system\notice\SystemNotice;
  5. class SystemNoticeDao extends BaseDao
  6. {
  7. protected function getModel(): string
  8. {
  9. return SystemNotice::class;
  10. }
  11. public function search(array $where)
  12. {
  13. return SystemNotice::getDB()->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
  14. $query->whereLike('notice_title|notice_content', '%' . $where['keyword'] . '%');
  15. })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
  16. getModelTime($query, $where['date'], 'create_time');
  17. })->where('is_del', 0);
  18. }
  19. }