first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Attraction;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Attraction>
|
||||
*/
|
||||
class AttractionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$categories = ['museum', 'restaurant', 'historic', 'park', 'cultural', 'entertainment', 'other'];
|
||||
|
||||
return [
|
||||
'city_id' => \App\Models\City::factory(),
|
||||
'name' => fake()->company() . ' ' . fake()->randomElement(['Museum', 'Restaurant', 'Park', 'Theater', 'Gallery']),
|
||||
'description' => fake()->paragraph(),
|
||||
'latitude' => fake()->latitude(),
|
||||
'longitude' => fake()->longitude(),
|
||||
'category' => fake()->randomElement($categories),
|
||||
'source' => fake()->randomElement(['opentripmap', 'overpass', 'wikipedia']),
|
||||
'source_id' => (string) fake()->randomNumber(8),
|
||||
'rating' => fake()->optional(0.7)->randomFloat(2, 1, 5),
|
||||
'image_url' => fake()->optional(0.5)->imageUrl(),
|
||||
'cached_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<City>
|
||||
*/
|
||||
class CityFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->city();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => \Illuminate\Support\Str::slug($name) . '-' . fake()->randomNumber(3),
|
||||
'country' => fake()->country(),
|
||||
'latitude' => fake()->latitude(),
|
||||
'longitude' => fake()->longitude(),
|
||||
'wikipedia_summary' => fake()->paragraph(3),
|
||||
'wikipedia_url' => fake()->url(),
|
||||
'wikipedia_page_id' => fake()->randomNumber(6),
|
||||
'wikipedia_cached_at' => now(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user