Skip to content

Commit 8e3b2dc

Browse files
committed
Update migration and factory
1 parent 742dccc commit 8e3b2dc

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

database/factories/RequestLogFactory.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,34 @@ class RequestLogFactory extends Factory
1212
public function definition()
1313
{
1414
return [
15+
'uuid' => $this->faker->uuid,
16+
'ip' => $this->faker->ipv4,
17+
'session' => null,
18+
'status' => $this->faker->randomElement([200, 201, 202, 204, 300, 301, 302, 303, 304, 400, 401, 402, 403, 404, 405, 406, 422, 429, 500, 501, 502, 503, 504]),
19+
'method' => $this->faker->randomElements(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
20+
'route' => $this->faker->domainWord().'.'.$this->faker->randomElements(['index', 'create', 'store', 'show', 'edit', 'update', 'destroy']),
21+
'path' => null,
22+
'headers' => $this->getHeaders(),
23+
'payload' => $this->getPayload(),
24+
'response_headers' => $this->getHeaders(),
25+
'response_body' => $this->faker->sentence(),
26+
'time' => $this->faker->numberBetween(100, 30000),
27+
'memory' => $this->faker->randomFloat(1, 1, 100),
28+
];
29+
}
1530

31+
protected function getPayload(): array
32+
{
33+
return [
34+
'type' => $this->faker->mimeType(),
35+
'extension' => $this->faker->fileExtension(),
36+
];
37+
}
38+
39+
protected function getHeaders(): array
40+
{
41+
return [
42+
'User-Agent' => $this->faker->userAgent(),
1643
];
1744
}
1845
}

database/migrations/create_request_logs_table.php.stub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ return new class extends Migration
1717
$table->string('session')->nullable();
1818
$table->unsignedSmallInteger('status')->nullable();
1919
$table->string('method')->nullable();
20-
$table->text('route')->nullable(); // Not all routes needs to have a name
21-
$table->text('path')->nullable();
20+
$table->string('route')->nullable(); // Not all routes needs to have a name
21+
$table->string('path')->nullable();
2222
$table->json('headers')->nullable();
2323
$table->json('payload')->nullable();
2424
$table->json('response_headers')->nullable();

0 commit comments

Comments
 (0)