Completed
Push — master ( fb58fa...265b9c )
by ARCANEDEV
08:46
created

SessionActivity::error()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php namespace Arcanedev\LaravelTracker\Models;
2
3
/**
4
 * Class     SessionActivity
5
 *
6
 * @package  Arcanedev\LaravelTracker\Models
7
 * @author   ARCANEDEV <[email protected]>
8
 *
9
 * @property  int             id
10
 * @property  int             session_id
11
 * @property  int             path_id
12
 * @property  int             query_id
13
 * @property  int             referrer_id
14
 * @property  string          method
15
 * @property  int             route_path_id
16
 * @property  bool            is_ajax
17
 * @property  bool            is_secure
18
 * @property  bool            is_json
19
 * @property  bool            wants_json
20
 * @property  int             error_id
21
 * @property  \Carbon\Carbon  created_at
22
 * @property  \Carbon\Carbon  updated_at
23
 *
24
 * @property  \Arcanedev\LaravelTracker\Models\Session  session
25
 * @property  \Arcanedev\LaravelTracker\Models\Path     path
26
 * @property  \Arcanedev\LaravelTracker\Models\Query    queryRel
27
 * @property  \Arcanedev\LaravelTracker\Models\Referer  referer
28
 * @property  \Arcanedev\LaravelTracker\Models\Error    error
29
 */
30
class SessionActivity extends Model
31
{
32
    /* ------------------------------------------------------------------------------------------------
33
     |  Properties
34
     | ------------------------------------------------------------------------------------------------
35
     */
36
    /**
37
     * The table associated with the model.
38
     *
39
     * @var string
40
     */
41
    protected $table = 'session_activities';
42
43
    /**
44
     * The attributes that are mass assignable.
45
     *
46
     * @var array
47
     */
48
    protected $fillable = [
49
        'session_id',
50
        'path_id',
51
        'query_id',
52
        'referrer_id',
53
        'method',
54
        'route_path_id',
55
        'is_ajax',
56
        'is_secure',
57
        'is_json',
58
        'wants_json',
59
        'error_id',
60
    ];
61
62
    /**
63
     * The attributes that should be cast to native types.
64
     *
65
     * @var array
66
     */
67
    protected $casts = [
68
        'id'            => 'integer',
69
        'session_id'    => 'integer',
70
        'path_id'       => 'integer',
71
        'query_id'      => 'integer',
72
        'referrer_id'   => 'integer',
73
        'route_path_id' => 'integer',
74
        'is_ajax'       => 'boolean',
75
        'is_secure'     => 'boolean',
76
        'is_json'       => 'boolean',
77
        'wants_json'    => 'boolean',
78
        'error_id'      => 'integer',
79
    ];
80
81
    /* ------------------------------------------------------------------------------------------------
82
     |  Relationships
83
     | ------------------------------------------------------------------------------------------------
84
     */
85
    /**
86
     * Session relationship.
87
     *
88
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
89
     */
90
    public function session()
91
    {
92
        return $this->belongsTo(
93
            $this->getConfig('models.session', Session::class)
94
        );
95
    }
96
97
    /**
98
     * Path relationship.
99
     *
100
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
101
     */
102
    public function path()
103
    {
104
        return $this->belongsTo(
105
            $this->getConfig('models.path', Path::class)
106
        );
107
    }
108
109
    /**
110
     * Query relationship.
111
     *
112
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
113
     */
114
    public function queryRel()
115
    {
116
        return $this->belongsTo(
117
            $this->getConfig('models.query', Query::class)
118
        );
119
    }
120
121
    /**
122
     * Referrer relationship.
123
     *
124
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
125
     */
126
    public function referrer()
127
    {
128
        return $this->belongsTo(
129
            $this->getConfig('models.referrer', Referer::class)
130
        );
131
    }
132
133
    /**
134
     * Error relationship.
135
     *
136
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
137
     */
138
    public function error()
139
    {
140
        return $this->belongsTo(
141
            $this->getConfig('models.error', Error::class)
142
        );
143
    }
144
}
145