This commit is contained in:
foobar
2022-08-21 21:39:06 +02:00
commit 27c1969aaa
7354 changed files with 897064 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace Database\Factories;
use App\Models\City;
use App\Models\WeatherData;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\WeatherData>
*/
class WeatherDataFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
protected $model = WeatherData::class;
public function definition()
{
$weatherDescriptionIconCollection = collect([
'Partly cloudy' => 'https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png',
'Sunny' => 'https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png',
'Light Rain' => 'https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0017_cloudy_with_light_rain.png',
'Mist' => 'https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0006_mist.png',
'Clear' => 'https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0008_clear_sky_night.png',
'Heavy Rain at Night' => 'https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0034_cloudy_with_heavy_rain_night.png'
]);
$weatherDescription = fake()->randomElement($weatherDescriptionIconCollection->keys());
$weatherIcon = $weatherDescriptionIconCollection->get($weatherDescription);
return [
'city_id' => City::factory(),
'current_temperature' => fake()->numberBetween(-20, 40),
'weather_icon' => $weatherIcon,
'weather_description' => $weatherDescription,
'wind_speed' => fake()->numberBetween(0, 200),
'wind_dir' => fake()->randomElement(['N', 'E', 'S', 'W', 'NE', 'SE', 'SW', 'NW', 'NNE', 'ENE', 'ESE', 'SSE', 'SSW', 'WSW', 'WNW', 'NNW']),
'localtime_epoch' => fake()->numberBetween(1600000000, 1660972200)
];
}
}