Visit::author()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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