Ip   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A log() 0 4 1
A logs() 0 4 1
A scopeBlocked() 0 10 2
1
<?php
2
3
namespace Spinzar\Firewall\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class Ip extends Model
9
{
10
    use SoftDeletes;
11
12
    protected $table = 'firewall_ips';
13
14
    protected $dates = ['deleted_at'];
15
16
    protected $fillable = ['ip', 'log_id', 'blocked'];
17
18
    public function log()
19
    {
20
        return $this->belongsTo('Spinzar\Firewall\Models\Log');
21
    }
22
23
    public function logs()
24
    {
25
        return $this->hasMany('Spinzar\Firewall\Models\Log', 'ip', 'ip');
26
    }
27
28
    public function scopeBlocked($query, $ip = null)
29
    {
30
        $q = $query->where('blocked', 1);
31
32
        if ($ip) {
33
            $q = $query->where('ip', $ip);
34
        }
35
36
        return $q;
37
    }
38
}
39