Example #1
1
 /**
  *
  * @param string $username
  * @param string $ip
  *
  * @return mixed
  */
 public function search($username, $ip)
 {
     $logs = tap($this->model->with('user'), function ($query) use($username, $ip) {
         if ($username && !$ip) {
             $query->join('users', function ($join) use($username) {
                 $join->where('users.username', 'like', $username . '%');
             });
         }
         if (!$username && $ip) {
             $query->where('operator_ip', 'like', $ip . '%');
         }
         if ($username && $ip) {
             $query->join('users', function ($join) use($username, $ip) {
                 $join->where('system_logs.operator_ip', 'like', $ip . '%')->where('users.username', 'like', $username . '%');
             });
         }
     })->paginate(getPerPageRows());
     return $logs;
 }
Example #2
0
 /**
  * @param array $with
  * @param string $by
  * @param array $columns
  * @param string $pageName
  * @param null $page
  *
  * @return mixed
  */
 public function paging($with = [], $by = 'created_at', $columns = ['*'], $pageName = 'page', $page = null)
 {
     return $this->withAndLatest($with, $by)->paginate(getPerPageRows(), $columns, $pageName, $page);
 }
Example #3
0
 /**
  * 搜索用户
  *
  * @param string $name
  *
  * @return mixed
  */
 public function search($name)
 {
     $users = $this->model->where('username', 'like', $name . '%')->orWhere('realname', 'like', $name . '%')->paginate(getPerPageRows());
     return $users;
 }
Example #4
0
 /**
  * 搜索文章
  *
  * @param $q
  *
  * @return mixed
  */
 public function search($q)
 {
     $articles = $this->model->where('title', 'like', $q . '%')->paginate(getPerPageRows());
     return $articles;
 }