TrackSpam::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sfneal\Honeypot\Models;
4
5
use Database\Factories\TrackSpamFactory;
6
use Illuminate\Database\Eloquent\Factories\HasFactory;
7
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8
use Sfneal\Models\Model;
9
use Sfneal\Scopes\CreatedOrderScope;
10
use Sfneal\Tracking\Models\TrackTraffic;
11
12
class TrackSpam extends Model
13
{
14
    use HasFactory;
15
16
    /**
17
     * The "booting" method of the model.
18
     *
19
     * @return void
20
     */
21
    protected static function boot()
22
    {
23
        parent::boot();
24
        static::addGlobalScope(new CreatedOrderScope('desc'));
25
    }
26
27
    protected $table = 'track_spam';
28
    protected $primaryKey = 'track_spam_id';
29
30
    protected $fillable = [
31
        'track_spam_id',
32
        'request_token',
33
    ];
34
35
    /**
36
     * @var array Relationships that are always eager loaded
37
     */
38
    protected $with = [
39
        'tracking',
40
    ];
41
42
    /**
43
     * Create a new factory instance for the model.
44
     *
45
     * @return TrackSpamFactory
46
     */
47
    protected static function newFactory(): TrackSpamFactory
48
    {
49
        return new TrackSpamFactory();
50
    }
51
52
    /**
53
     * Related TrackTraffic data.
54
     *
55
     * @return BelongsTo
56
     */
57
    public function tracking()
58
    {
59
        return $this->belongsTo(TrackTraffic::class, 'request_token', 'request_token');
60
    }
61
}
62