|
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; |
|
|
|
|
|
|
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
|
|
|
|