feat: add HasFactory and factories for ApiLog, BrentPrice, PricePrediction
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
27
database/factories/BrentPriceFactory.php
Normal file
27
database/factories/BrentPriceFactory.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BrentPrice;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/** @extends Factory<BrentPrice> */
|
||||
class BrentPriceFactory extends Factory
|
||||
{
|
||||
/** @var array<int, string> */
|
||||
private static array $usedDates = [];
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
do {
|
||||
$date = fake()->dateTimeBetween('-60 days')->format('Y-m-d');
|
||||
} while (in_array($date, self::$usedDates, true));
|
||||
|
||||
self::$usedDates[] = $date;
|
||||
|
||||
return [
|
||||
'date' => $date,
|
||||
'price_usd' => fake()->randomFloat(2, 65, 95),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user