Skip to content

Instantly share code, notes, and snippets.

@DavidGarciaCat
Last active January 15, 2019 18:08
Show Gist options
  • Save DavidGarciaCat/57eef185b8d67b02e7cb00b4a8f3cbda to your computer and use it in GitHub Desktop.
Save DavidGarciaCat/57eef185b8d67b02e7cb00b4a8f3cbda to your computer and use it in GitHub Desktop.
<?php
class County
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="State", inversedBy="counties")
*/
private $state;
/**
* @return State
*/
public function getState(): State
{
return $this->state;
}
}
<?php
class State
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="County", mappedBy="state")
*/
private $counties;
/**
* @return County[]|Collection
*/
public function getCounties()
{
return $this->counties;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment