*/
private $updatedAt;
- /**
- * @var string
- *
- * @ORM\Column(name="user_id", type="decimal", precision=10, scale=0, nullable=true)
- */
- private $userId;
-
/**
* @var string
*
*/
private $isPublic;
+ /**
+ * @ORM\ManyToOne(targetEntity="User", inversedBy="entries")
+ */
+ private $user;
+
+ /*
+ * @param User $user
+ */
+ public function __construct(User $user)
+ {
+ $this->user = $user;
+ }
+
/**
* Get id
*
}
/**
- * Set userId
- *
- * @param string $userId
- * @return Entry
- */
- public function setUserId($userId)
- {
- $this->userId = $userId;
-
- return $this;
- }
-
- /**
- * Get userId
- *
- * @return string
+ * @return User
*/
- public function getUserId()
+ public function getUser()
{
- return $this->userId;
+ return $this->user;
}
/**
namespace Wallabag\CoreBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
*/
private $updatedAt;
+ /**
+ * @ORM\OneToMany(targetEntity="Entry", mappedBy="user", cascade={"remove"})
+ */
+ private $entries;
+
public function __construct()
{
$this->isActive = true;
- $this->salt = md5(uniqid(null, true));
+ $this->salt = md5(uniqid(null, true));
+ $this->entries = new ArrayCollection();
}
/**
return $this->updatedAt;
}
+ /**
+ * @param Entry $entry
+ *
+ * @return User
+ */
+ public function addEntry(Entry $entry)
+ {
+ $this->entries[] = $entry;
+
+ return $this;
+ }
+
+ /**
+ * @return ArrayCollection<Entry>
+ */
+ public function getEntries()
+ {
+ return $this->entries;
+ }
+
/**
* @inheritDoc
*/