File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Illuminate \Database \Migrations \Migration ;
4
+ use Illuminate \Database \Schema \Blueprint ;
5
+ use Illuminate \Support \Facades \Schema ;
6
+
7
+ return new class extends Migration {
8
+ /**
9
+ * Run the migrations.
10
+ */
11
+ public function up (): void
12
+ {
13
+ Schema::create ('log_events ' , function (Blueprint $ table ) {
14
+ $ table ->uuid ('id ' )->primary ();
15
+ $ table ->foreignUuid ('log_id ' )->index ()->constrained ()->cascadeOnDelete ();
16
+ $ table ->string ('name ' );
17
+ $ table ->timestamps ();
18
+ });
19
+ }
20
+
21
+ /**
22
+ * Reverse the migrations.
23
+ */
24
+ public function down (): void
25
+ {
26
+ Schema::dropIfExists ('log_events ' );
27
+ }
28
+ };
Original file line number Diff line number Diff line change 21
21
* @property \MailCarrier\Enums\LogStatus $status
22
22
* @property string|null $trigger
23
23
* @property string|null $subject
24
+ * @property string|null $message_id
24
25
* @property \MailCarrier\Dto\ContactDto $sender
25
26
* @property \MailCarrier\Dto\ContactDto|null $replyTo
26
27
* @property \Illuminate\Support\Collection<MailCarrier\Dto\ContactDto>|null $cc
37
38
* @property array|null $metadata
38
39
* @property-read \MailCarrier\Models\Template|null $template
39
40
* @property-read \Illuminate\Database\Eloquent\Collection<int, \MailCarrier\Models\Attachment> $attachments
41
+ * @property-read \Illuminate\Database\Eloquent\Collection<int, \MailCarrier\Models\LogEvent> $events
40
42
*/
41
43
class Log extends Model
42
44
{
@@ -119,6 +121,14 @@ public function attachments(): HasMany
119
121
return $ this ->hasMany (Attachment::class);
120
122
}
121
123
124
+ /**
125
+ * Get the log's events.
126
+ */
127
+ public function events (): HasMany
128
+ {
129
+ return $ this ->hasMany (LogEvent::class);
130
+ }
131
+
122
132
/**
123
133
* Get the prunable model query.
124
134
*/
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace MailCarrier \Models ;
4
+
5
+ use Illuminate \Database \Eloquent \Factories \HasFactory ;
6
+ use Illuminate \Database \Eloquent \Model ;
7
+ use Illuminate \Database \Eloquent \Relations \BelongsTo ;
8
+ use MailCarrier \Models \Concerns \IsUuid ;
9
+
10
+ /**
11
+ * @property string $id
12
+ * @property string $log_id
13
+ * @property string $name
14
+ * @property \Carbon\CarbonImmutable $created_at
15
+ * @property \Carbon\CarbonImmutable $updated_at
16
+ * @property-read \MailCarrier\Models\Log $log
17
+ */
18
+ class LogEvent extends Model
19
+ {
20
+ use HasFactory;
21
+ use IsUuid;
22
+
23
+ /**
24
+ * Indicates if the IDs are auto-incrementing.
25
+ */
26
+ public $ incrementing = false ;
27
+
28
+ /**
29
+ * The data type of the auto-incrementing ID.
30
+ */
31
+ protected $ keyType = 'string ' ;
32
+
33
+ /**
34
+ * The attributes that are mass assignable.
35
+ *
36
+ * @var array<int, string>
37
+ */
38
+ protected $ fillable = [
39
+ 'log_id ' ,
40
+ 'name ' ,
41
+ ];
42
+
43
+ /**
44
+ * Get the log that owns the event.
45
+ */
46
+ public function log (): BelongsTo
47
+ {
48
+ return $ this ->belongsTo (Log::class);
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments