Пример #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');
 }