Skip to content

Instantly share code, notes, and snippets.

@Zayon
Created December 31, 2018 13:27
Show Gist options
  • Save Zayon/3c6ff65d5547e57cbec8083377fdf5cf to your computer and use it in GitHub Desktop.
Save Zayon/3c6ff65d5547e57cbec8083377fdf5cf to your computer and use it in GitHub Desktop.
Fixtures - Entities
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
*/
class Product
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*
* @var int
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @var string
*/
private $name;
/**
* @ORM\Column(type="decimal", precision=10, scale=0)
*
* @var float
*/
private $price;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ProductCategory")
* @ORM\JoinColumn(nullable=false)
*
* @var ProductCategory
*/
private $category;
public function getId(): int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getPrice(): float
{
return $this->price;
}
public function setPrice($price): self
{
$this->price = $price;
return $this;
}
public function getCategory(): ProductCategory
{
return $this->category;
}
public function setCategory(ProductCategory $category): self
{
$this->category = $category;
return $this;
}
}
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductCategoryRepository")
*/
class ProductCategory
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment