45 lines
1015 B
PHP
45 lines
1015 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Comment;
|
|
use App\Models\Course;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Comment>
|
|
*/
|
|
class CommentFactory extends Factory
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'commentable_id' => Course::factory(),
|
|
'commentable_type' => Course::class,
|
|
'name_surname' => fake()->name(),
|
|
'phone' => fake()->phoneNumber(),
|
|
'body' => fake()->paragraph(),
|
|
'admin_reply' => null,
|
|
'is_approved' => false,
|
|
];
|
|
}
|
|
|
|
public function approved(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_approved' => true,
|
|
]);
|
|
}
|
|
|
|
public function withReply(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'admin_reply' => fake()->paragraph(),
|
|
'is_approved' => true,
|
|
]);
|
|
}
|
|
}
|