File: /home/armgroup/libs/database/factories/CategoryFactory.php
<?php
namespace Database\Factories;
use App\Models\Category;
use App\Models\Contact;
use Illuminate\Database\Eloquent\Factories\Factory;
class CategoryFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Category::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'type' => Category::TYPE[array_rand(Category::TYPE)]['className'],
'name' => $this->faker->sentence(5),
'slug' => $this->faker->unique()->slug,
'status' => rand(0, 1),
];
}
public function contactType()
{
return $this->state(function (array $attributes) {
return [
'type' => Contact::class,
'status' => true,
'name' => 'پیشنهاد',
'slug' => 'پیشنهاد',
];
});
}
}