1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SaasReady\Models; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
|
|
|
|
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
|
|
|
7
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo; |
|
|
|
|
8
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo; |
|
|
|
|
9
|
|
|
use SaasReady\Contracts\EventSourcingContract; |
10
|
|
|
use SaasReady\Traits\EloquentBuilderMixin; |
11
|
|
|
use SaasReady\Traits\HasUuid; |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @property-read int $id |
15
|
|
|
* @property int $model_id |
16
|
|
|
* @property string $model_type |
17
|
|
|
* @property string $name |
18
|
|
|
* @property string $category |
19
|
|
|
* @property array $properties |
20
|
|
|
* @property int $user_id |
21
|
|
|
* @property ?Carbon $created_at |
22
|
|
|
* @property ?Carbon $updated_at |
23
|
|
|
* |
24
|
|
|
* @property-read Model $model |
25
|
|
|
* @property-read ?Model $user |
26
|
|
|
* |
27
|
|
|
* @mixin EloquentBuilderMixin |
28
|
|
|
*/ |
29
|
|
|
class Event extends Model |
30
|
|
|
{ |
31
|
|
|
use HasUuid; |
32
|
|
|
|
33
|
|
|
protected $table = 'events'; |
34
|
|
|
|
35
|
|
|
protected $fillable = [ |
36
|
|
|
'name', |
37
|
|
|
'user_id', |
38
|
|
|
'model_id', |
39
|
|
|
'model_type', |
40
|
|
|
'category', |
41
|
|
|
'properties', |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
protected $casts = [ |
45
|
|
|
'user_id' => 'int', |
46
|
|
|
'properties' => 'array', |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* An Event belongsTo a model |
51
|
|
|
*/ |
52
|
|
|
public function model(): MorphTo |
53
|
|
|
{ |
54
|
|
|
return $this->morphTo('model'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* An Event belongs to a User |
59
|
|
|
*/ |
60
|
|
|
public function user(): BelongsTo |
61
|
|
|
{ |
62
|
|
|
return $this->belongsTo( |
63
|
|
|
config('saas-ready.event-sourcing.user-model'), |
|
|
|
|
64
|
|
|
'user_id' |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Quickly create a new instance from Contract |
70
|
|
|
*/ |
71
|
|
|
public static function createFromContract(EventSourcingContract $contractor): Event |
72
|
|
|
{ |
73
|
|
|
$baseModel = $contractor->getModel(); |
74
|
|
|
|
75
|
|
|
return Event::create([ |
76
|
|
|
'name' => class_basename($contractor), |
|
|
|
|
77
|
|
|
'category' => $contractor->getCategory(), |
78
|
|
|
'properties' => $contractor->getEventProperties(), |
79
|
|
|
'model_id' => $baseModel->getKey(), |
80
|
|
|
'model_type' => $baseModel->getMorphClass(), |
81
|
|
|
'user_id' => $contractor->getUser()?->getKey(), |
82
|
|
|
]); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths