예제 #1
0
 public function blockIp()
 {
     try {
         IpBans::transaction(function () {
             $ban = IpBans::create(array_merge($this->params()->ban, ['banned_by' => current_user()->id]));
             if (IpBans::where("id = ? and ip_addr = ?", $ban->id, $this->request()->remoteIp())->first()) {
                 throw new CanNotBanSelf();
             }
         });
     } catch (CanNotBanSelf $e) {
         $this->notice("You can not ban yourself");
     }
     $this->redirectTo('user#show_blocked_users');
 }
예제 #2
0
 public function get_ip_ban()
 {
     $ban = IpBans::where("ip_addr = ?", $this->request()->remoteIp())->first();
     return $ban ?: null;
 }