<?php declare(strict_types=1);
/**
 * This file is part of the SplendidBear Websites' projects.
 *
 * Copyright (c) 2026 @ www.splendidbear.org
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace App\Entity;

use App\Repository\ContactMessageRepository;
use DateTimeImmutable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\Table;

/**
 * Class ContactMessage
 *
 * @package  App\Entity
 * @author   Lang <https://www.splendidbear.org>
 * @category Class
 * @license  https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
 * @link     www.splendidbear.org
 * @since    2026. 04. 15.
 */
#[Entity(repositoryClass: ContactMessageRepository::class), Table(name: 'contact_messages')]
class ContactMessage
{
    #[Id, GeneratedValue, Column]
    public private(set) ?int $id = null;

    #[Column]
    public string $name;

    #[Column]
    public string $email;

    #[Column(type: Types::TEXT)]
    public string $content;

    #[Column]
    public bool $consent = false;

    #[Column]
    public private(set) DateTimeImmutable $createdAt;

    #[Column(length: 45, nullable: true)]
    public ?string $ipAddress = null;


    public function __construct()
    {
        $this->createdAt = new DateTimeImmutable();
    }
}
