src/Entity/Company.php line 25
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Controller\Api\CompanyController;
use App\Repository\CompanyRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CompanyRepository::class)]
#[ApiResource(
operations: [
new GetCollection(),
new Get(),
new Post(
routeName: 'app_api_companies',
controller: CompanyController::class
),
new Put()
]
)]
class Company
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $adresse = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $city = null;
#[ORM\Column(length: 255)]
private ?string $numberSociety = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $emailSociety = null;
#[ORM\OneToOne(mappedBy: 'company', cascade: ['persist', 'remove'])]
private ?User $user = null;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getAdresse(): ?string
{
return $this->adresse;
}
public function setAdresse(?string $adresse): static
{
$this->adresse = $adresse;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getNumberSociety(): ?string
{
return $this->numberSociety;
}
public function setNumberSociety(string $numberSociety): static
{
$this->numberSociety = $numberSociety;
return $this;
}
public function getEmailSociety(): ?string
{
return $this->emailSociety;
}
public function setEmailSociety(?string $emailSociety): static
{
$this->emailSociety = $emailSociety;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
// unset the owning side of the relation if necessary
if ($user === null && $this->user !== null) {
$this->user->setCompany(null);
}
// set the owning side of the relation if necessary
if ($user !== null && $user->getCompany() !== $this) {
$user->setCompany($this);
}
$this->user = $user;
return $this;
}
}