Step 2: Data models and migrations (Email, EmailBody, factories)
This commit is contained in:
35
database/factories/EmailBodyFactory.php
Normal file
35
database/factories/EmailBodyFactory.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\EmailBody;
|
||||
|
||||
class EmailBodyFactory
|
||||
{
|
||||
/**
|
||||
* Create a new EmailBody instance with the given attributes.
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public static function make(array $attributes = []): EmailBody
|
||||
{
|
||||
return new EmailBody(array_merge([
|
||||
'unique_id_hash' => hash('sha256', fake()->uuid()),
|
||||
'body_text' => fake()->paragraphs(3, true),
|
||||
'body_html' => '<p>'.implode('</p><p>', fake()->paragraphs(3)).'</p>',
|
||||
], $attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and persist a new EmailBody instance.
|
||||
*
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
public static function create(array $attributes = []): EmailBody
|
||||
{
|
||||
$body = static::make($attributes);
|
||||
$body->save();
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user