Skip to content

Commit b6a3850

Browse files
committed
catch exception instead of checking table exists
1 parent 924529c commit b6a3850

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Middleware/Ip.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44

55
use Akaunting\Firewall\Abstracts\Middleware;
66
use Akaunting\Firewall\Models\Ip as Model;
7-
use Illuminate\Support\Facades\Schema;
7+
use Illuminate\Database\QueryException;
88

99
class Ip extends Middleware
1010
{
1111
public function check($patterns)
1212
{
13-
if (!Schema::hasTable('firewall_ips')) {
14-
return false;
13+
$status = false;
14+
15+
try {
16+
$status = Model::blocked($this->ip())->pluck('id')->first();
17+
} catch (QueryException $e) {
18+
// Base table or view not found
19+
//$status = ($e->getCode() == '42S02') ? false : true;
1520
}
1621

17-
return Model::blocked($this->ip())->pluck('id')->first();
22+
return $status;
1823
}
1924
}

0 commit comments

Comments
 (0)