<?php

declare(strict_types=1);

namespace App\Entity\Access;

// use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Put;
use Doctrine\ORM\Mapping as ORM;

/**
 * Préférence pour un Access.
 */
// #[Auditable]
#[ORM\Entity]
#[ApiResource(
    operations: [
        new Get(
            security: 'object.getAccess().getId() == user.getId()'
        ),
        new Put(
            security: 'object.getAccess().getId() == user.getId()'
        ),
    ]
)]
class Preferences
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    #[ORM\OneToOne(inversedBy: 'preferences', fetch: 'EAGER')]
    #[ORM\JoinColumn(nullable: true)]
    private ?Access $access = null;

    #[ORM\Column(options: ['default' => true])]
    private bool $messageReport = true;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getAccess(): ?Access
    {
        return $this->access;
    }

    public function setAccess(?Access $access): self
    {
        $this->access = $access;

        return $this;
    }

    public function getMessageReport(): ?bool
    {
        return $this->messageReport;
    }

    public function setMessageReport(bool $messageReport): self
    {
        $this->messageReport = $messageReport;

        return $this;
    }
}
