Add NoteShares

This commit is contained in:
Ryan Prather 2024-07-02 19:24:48 -04:00
parent 8aa1652283
commit 82700e2dc5
2 changed files with 149 additions and 0 deletions

106
src/Entity/NoteShares.php Normal file
View File

@ -0,0 +1,106 @@
<?php
namespace App\Entity;
use App\Repository\NoteSharesRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NoteSharesRepository::class)]
class NoteShares
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'noteShares')]
#[ORM\JoinColumn(nullable: false)]
private ?User $owner = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?User $share = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?Note $note = null;
/**
* Retrieves the ID of the NoteShares entity.
*
* @return int|null The ID of the NoteShares entity, or null if not set.
*/
public function getId(): ?int
{
return $this->id;
}
/**
* Retrieves the owner of the object.
*
* @return User|null The owner of the object, or null if not set.
*/
public function getOwner(): ?User
{
return $this->owner;
}
/**
* A description of the entire PHP function.
*
* @param User|null $owner description
* @return static
*/
public function setOwner(?User $owner): static
{
$this->owner = $owner;
return $this;
}
/**
* Retrieves the share for the current instance.
*
* @return User|null The user who shares this instance.
*/
public function getShare(): ?User
{
return $this->share;
}
/**
* Set the share for the current instance.
*
* @param User|null $share The user to set as the share.
* @return static The current instance.
*/
public function setShare(?User $share): static
{
$this->share = $share;
return $this;
}
/**
* Retrieves the associated Note object.
*
* @return Note|null The associated Note object, or null if not found.
*/
public function getNote(): ?Note
{
return $this->note;
}
/**
* Set the note for this NoteShares entity.
*
* @param Note|null $note The note to set
* @return static
*/
public function setNote(?Note $note): static
{
$this->note = $note;
return $this;
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Repository;
use App\Entity\NoteShares;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<NoteShares>
*/
class NoteSharesRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, NoteShares::class);
}
// /**
// * @return NoteShares[] Returns an array of NoteShares objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('n.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?NoteShares
// {
// return $this->createQueryBuilder('n')
// ->andWhere('n.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}