feat: add HasFactory and factories for ApiLog, BrentPrice, PricePrediction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ovidiu U
2026-04-04 13:59:55 +01:00
parent efba3cbfd6
commit cf187f9721
6 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use App\Models\ApiLog;
use Illuminate\Database\Eloquent\Factories\Factory;
/** @extends Factory<ApiLog> */
class ApiLogFactory extends Factory
{
public function definition(): array
{
return [
'service' => fake()->randomElement(['fuel_finder', 'fred', 'anthropic', 'postcodes_io']),
'method' => fake()->randomElement(['GET', 'POST']),
'url' => fake()->url(),
'status_code' => fake()->randomElement([200, 200, 200, 401, 429, 500]),
'duration_ms' => fake()->numberBetween(50, 2000),
'error' => null,
'created_at' => fake()->dateTimeBetween('-7 days'),
];
}
public function failed(): static
{
return $this->state([
'status_code' => fake()->randomElement([400, 401, 403, 429, 500, 503]),
'error' => fake()->sentence(),
]);
}
}