Completed
Push — master ( 3a2708...31f349 )
by ARCANEDEV
13s
created

Referer::searchTerms()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\LaravelTracker\Models;
2
3
/**
4
 * Class     Referer
5
 *
6
 * @package  Arcanedev\LaravelTracker\Models
7
 * @author   ARCANEDEV <[email protected]>
8
 *
9
 * @property  int             id
10
 * @property  int             domain_id
11
 * @property  string          url
12
 * @property  string          host
13
 * @property  string          medium
14
 * @property  string          source
15
 * @property  string          search_terms_hash
16
 * @property  \Carbon\Carbon  created_at
17
 * @property  \Carbon\Carbon  updated_at
18
 *
19
 * @property  \Arcanedev\LaravelTracker\Models\Domain   domain
20
 * @property  \Illuminate\Database\Eloquent\Collection  search_terms
21
 */
22
class Referer extends AbstractModel
23
{
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Properties
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * The table associated with the model.
30
     *
31
     * @var string
32
     */
33
    protected $table = 'referers';
34
35
    /**
36
     * The attributes that are mass assignable.
37
     *
38
     * @var array
39
     */
40
    protected $fillable = [
41
        'url',
42
        'host',
43
        'domain_id',
44
        'medium',
45
        'source',
46
        'search_terms_hash',
47
    ];
48
49
    /**
50
     * The attributes that should be cast to native types.
51
     *
52
     * @var array
53
     */
54
    protected $casts = [
55
        'id'        => 'integer',
56
        'domain_id' => 'integer',
57
    ];
58
59
    /* ------------------------------------------------------------------------------------------------
60
     |  Relationships
61
     | ------------------------------------------------------------------------------------------------
62
     */
63
    /**
64
     * Domain relationship.
65
     *
66
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
67
     */
68
    public function domain()
69
    {
70
        return $this->belongsTo(
71
            $this->getModelClass(self::MODEL_DOMAIN, Domain::class)
72
        );
73
    }
74
75
    /**
76
     * Search terms relationship.
77
     *
78
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
79
     */
80 6
    public function searchTerms()
81
    {
82 6
        return $this->hasMany(
83 6
            $this->getModelClass(self::MODEL_REFERER_SEARCH_TERM, RefererSearchTerm::class)
84 3
        );
85
    }
86
}
87