- Rename IsCommenter trait to CanComment, Commenter interface to Commentator - Move models to Models/ namespace (Comment, Reaction, Attachment, Subscription) - Rename user_type/user_id polymorphic columns to commenter_type/commenter_id - Rename Config class to CommentsConfig, update config key tables->table_names - Rename getCommentName() to getCommentDisplayName() on commentator models - Add column_names config section for commenter morph customization - Add table_names config with all 5 tables individually configurable - Expand translation file with structured i18n groups - Update all Blade views, Livewire components, events, listeners, and tests
35 lines
777 B
PHP
35 lines
777 B
PHP
<?php
|
|
|
|
namespace Relaticle\Comments\Database\Factories;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Relaticle\Comments\Models\Comment;
|
|
|
|
class CommentFactory extends Factory
|
|
{
|
|
protected $model = Comment::class;
|
|
|
|
/** @return array<string, mixed> */
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'body' => '<p>'.fake()->paragraph().'</p>',
|
|
'edited_at' => null,
|
|
];
|
|
}
|
|
|
|
public function withParent(?Comment $parent = null): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'parent_id' => $parent?->id,
|
|
]);
|
|
}
|
|
|
|
public function edited(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'edited_at' => now(),
|
|
]);
|
|
}
|
|
}
|