Visit   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 40
ccs 0
cts 13
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A author() 0 4 1
A scopeActiveUsers() 0 6 1
1
<?php
2
3
namespace SET;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Visit extends Model
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $table = 'visits';
13
    /**
14
     * @var bool
15
     */
16
    public $timestamps = true;
17
    /**
18
     * @var array
19
     */
20
    protected $fillable = ['smo_code', 'poc', 'phone', 'comment', 'visit_date', 'expiration_date', 'author_id', 'user_id'];
21
22
    public function user()
23
    {
24
        return $this->belongsTo('SET\User');
25
    }
26
27
    public function author()
28
    {
29
        return $this->belongsTo('SET\User', 'author_id');
30
    }
31
32
    /**
33
     * Allows you to call activeUsers() on notes
34
     * to return only notes with active users.
35
     *
36
     * @param $query
37
     *
38
     * @return mixed
39
     */
40
    public function scopeActiveUsers($query)
41
    {
42
        return $query->whereHas('user', function ($q) {
43
            $q->where('status', 'active');
44
        });
45
    }
46
}
47