50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Models\Tool;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @extends Factory<Tool>
|
||
|
|
*/
|
||
|
|
class ToolFactory extends Factory
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
$name = fake()->unique()->company();
|
||
|
|
$categories = array_keys(config('tools.categories'));
|
||
|
|
|
||
|
|
return [
|
||
|
|
'name' => $name,
|
||
|
|
'slug' => Str::slug($name),
|
||
|
|
'description' => fake()->paragraph(),
|
||
|
|
'url' => fake()->url(),
|
||
|
|
'logo_url' => 'https://picsum.photos/seed/'.Str::slug($name).'/200',
|
||
|
|
'category' => fake()->randomElement($categories),
|
||
|
|
'subcategory' => fake()->randomElement(['Code Assistants', 'Image Generation', 'Chatbots', 'Automation', null]),
|
||
|
|
'tags' => fake()->randomElements(['free', 'api', 'open-source', 'freemium', 'chrome-extension'], rand(1, 3)),
|
||
|
|
'pricing' => fake()->randomElement(['Free', 'Freemium', '$10/month', '$29/month', 'Contact for pricing']),
|
||
|
|
'features' => fake()->sentences(3),
|
||
|
|
'views' => fake()->numberBetween(0, 5000),
|
||
|
|
'clicks' => fake()->numberBetween(0, 500),
|
||
|
|
'featured' => false,
|
||
|
|
'approved' => true,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function featured(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn () => ['featured' => true]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function pending(): static
|
||
|
|
{
|
||
|
|
return $this->state(fn () => ['approved' => false]);
|
||
|
|
}
|
||
|
|
}
|