2021-10-30 21:29:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
2023-05-24 09:06:15 +01:00
|
|
|
namespace Database\Factories\Activity\Models;
|
2021-10-30 21:29:59 +01:00
|
|
|
|
2025-10-24 14:22:53 +01:00
|
|
|
use BookStack\Users\Models\User;
|
2021-10-30 21:29:59 +01:00
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
|
|
class CommentFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2023-05-17 17:56:55 +01:00
|
|
|
protected $model = \BookStack\Activity\Models\Comment::class;
|
2021-10-30 21:29:59 +01:00
|
|
|
|
2025-10-24 10:18:52 +01:00
|
|
|
/**
|
|
|
|
|
* A static counter to provide a unique local_id for each comment.
|
|
|
|
|
*/
|
|
|
|
|
protected static int $nextLocalId = 1000;
|
|
|
|
|
|
2021-10-30 21:29:59 +01:00
|
|
|
/**
|
|
|
|
|
* Define the model's default state.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function definition()
|
|
|
|
|
{
|
|
|
|
|
$text = $this->faker->paragraph(1);
|
|
|
|
|
$html = '<p>' . $text . '</p>';
|
2025-10-24 10:18:52 +01:00
|
|
|
$nextLocalId = static::$nextLocalId++;
|
2021-10-30 21:29:59 +01:00
|
|
|
|
2025-10-24 14:22:53 +01:00
|
|
|
$user = User::query()->first();
|
|
|
|
|
|
2021-10-30 21:29:59 +01:00
|
|
|
return [
|
|
|
|
|
'html' => $html,
|
|
|
|
|
'parent_id' => null,
|
2025-10-24 10:18:52 +01:00
|
|
|
'local_id' => $nextLocalId,
|
2025-04-18 21:13:49 +01:00
|
|
|
'content_ref' => '',
|
|
|
|
|
'archived' => false,
|
2025-10-24 14:22:53 +01:00
|
|
|
'created_by' => $user ?? User::factory(),
|
|
|
|
|
'updated_by' => $user ?? User::factory(),
|
2021-10-30 21:29:59 +01:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|