Passed
Push — master ( 0bc69d...cc8e66 )
by Stephen
56s queued 13s
created

TrackAction::newFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Sfneal\Tracking\Models;
4
5
use Database\Factories\TrackActionFactory;
6
use Illuminate\Database\Eloquent\Builder;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
use Sfneal\Scopes\CreatedOrderScope;
9
use Sfneal\Scopes\IdOrderScope;
10
use Sfneal\Tracking\Builders\TrackActionBuilder;
11
use Sfneal\Tracking\Models\Base\Tracking;
12
use Sfneal\Tracking\Models\Traits\TrackingRelationships;
13
14
class TrackAction extends Tracking
15
{
16
    use HasFactory;
17
    use TrackingRelationships;
0 ignored issues
show
introduced by
The trait Sfneal\Tracking\Models\T...s\TrackingRelationships requires some properties which are not provided by Sfneal\Tracking\Models\TrackAction: $task, $planManagement, $project, $model_table, $plan, $taskRecord
Loading history...
18
19
    /**
20
     * The "booting" method of the model.
21
     *
22
     * @return void
23
     */
24
    protected static function boot()
25
    {
26
        parent::boot();
27
        static::addGlobalScope(new CreatedOrderScope());
28
        static::addGlobalScope(new IdOrderScope());
29
    }
30
31
    protected $table = 'track_action';
32
    protected $primaryKey = 'track_action_id';
33
34
    protected $fillable = [
35
        'track_action_id',
36
        'action',
37
        'model_table',
38
        'model_key',
39
        'model_changes',
40
    ];
41
42
    /**
43
     * The attributes that should be cast to native types.
44
     *
45
     * @var array
46
     */
47
    protected $casts = [
48
        'model_key' => 'int',
49
        'model_changes' => 'array',
50
    ];
51
52
    /**
53
     * Create a new factory instance for the model.
54
     *
55
     * @return TrackActionFactory
56
     */
57
    protected static function newFactory(): TrackActionFactory
58
    {
59
        return new TrackActionFactory();
60
    }
61
62
    /**
63
     * Query Builder.
64
     *
65
     * @param $query
66
     *
67
     * @return TrackActionBuilder()
68
     */
69
    public function newEloquentBuilder($query)
70
    {
71
        return new TrackActionBuilder($query);
72
    }
73
74
    /**
75
     * @return TrackActionBuilder|Builder
76
     */
77
    public static function query(): TrackActionBuilder
78
    {
79
        return parent::query();
80
    }
81
82
//    /**
83
//     * Retrieve the 'model_key' key attribute as an integer.
84
//     *
85
//     * @param $value
86
//     * @return int
87
//     */
88
//    public function getModelKeyAttribute($value): int
89
//    {
90
//        return intval($value);
91
//    }
92
}
93