2024-05-15 00:31:24 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use App\Models\SptVersion;
|
2024-09-15 23:05:38 -04:00
|
|
|
use App\Support\Version;
|
2024-05-15 00:31:24 -04:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
2024-09-11 23:08:58 -04:00
|
|
|
/**
|
|
|
|
* @extends Factory<SptVersion>
|
|
|
|
*/
|
2024-05-15 00:31:24 -04:00
|
|
|
class SptVersionFactory extends Factory
|
|
|
|
{
|
|
|
|
protected $model = SptVersion::class;
|
|
|
|
|
|
|
|
public function definition(): array
|
|
|
|
{
|
2024-09-15 23:05:38 -04:00
|
|
|
$versionString = $this->faker->numerify('#.#.#');
|
|
|
|
try {
|
|
|
|
$version = new Version($versionString);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$version = new Version('0.0.0');
|
|
|
|
}
|
|
|
|
|
2024-05-15 00:31:24 -04:00
|
|
|
return [
|
2024-09-15 23:05:38 -04:00
|
|
|
'version' => $versionString,
|
|
|
|
'version_major' => $version->getMajor(),
|
|
|
|
'version_minor' => $version->getMinor(),
|
|
|
|
'version_patch' => $version->getPatch(),
|
|
|
|
'version_pre_release' => $version->getPreRelease(),
|
2024-05-31 17:44:52 -04:00
|
|
|
'color_class' => $this->faker->randomElement(['red', 'green', 'emerald', 'lime', 'yellow', 'grey']),
|
2024-08-22 17:04:07 -04:00
|
|
|
'link' => $this->faker->url,
|
2024-05-15 00:31:24 -04:00
|
|
|
'created_at' => Carbon::now(),
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|