Passed
Push — master ( bba981...a1f61b )
by Stephen
02:25
created

TrackSpam::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sfneal\Honeypot\Models;
4
5
use Illuminate\Database\Eloquent\Relations\BelongsTo;
6
use Sfneal\Models\AbstractModel;
0 ignored issues
show
Bug introduced by
The type Sfneal\Models\AbstractModel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Sfneal\Scopes\CreatedOrderScope;
0 ignored issues
show
Bug introduced by
The type Sfneal\Scopes\CreatedOrderScope was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Sfneal\Scopes\IdOrderScope;
0 ignored issues
show
Bug introduced by
The type Sfneal\Scopes\IdOrderScope was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Support\Tracking\Models\TrackTraffic;
0 ignored issues
show
Bug introduced by
The type Support\Tracking\Models\TrackTraffic was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
class TrackSpam extends AbstractModel
12
{
13
    /**
14
     * The "booting" method of the model.
15
     *
16
     * @return void
17
     */
18
    protected static function boot()
19
    {
20
        parent::boot();
21
        static::addGlobalScope(new CreatedOrderScope('desc'));
22
        static::addGlobalScope(new IdOrderScope());
23
    }
24
25
    protected $connection = 'mysql';
26
    protected $table = 'track_spam';
27
    protected $primaryKey = 'track_spam_id';
28
29
    protected $fillable = [
30
        'track_spam_id',
31
        'request_token',
32
    ];
33
34
    /**
35
     * @var array Relationships that are always eager loaded
36
     */
37
    protected $with = [
38
        'tracking',
39
    ];
40
41
    /**
42
     * Related TrackTraffic data.
43
     *
44
     * @return BelongsTo
45
     */
46
    public function tracking()
47
    {
48
        return $this->belongsTo(TrackTraffic::class, 'request_token', 'request_token');
49
    }
50
51
    /**
52
     * Retrieve the created_at in date format.
53
     *
54
     * @return string
55
     */
56
    public function getCreatedAtDateAttribute(): string
57
    {
58
        return date('Y-m-d', strtotime($this->attributes['created_at']));
59
    }
60
61
    /**
62
     * Retrieve the created_at in date format.
63
     *
64
     * @return string
65
     */
66
    public function getCreatedAtTimeAttribute(): string
67
    {
68
        return date('h:i A', strtotime($this->attributes['created_at']));
69
    }
70
}
71