Reputation: 1142
I have an entity named User and i have a property $money. When someone registers I want to register him with money always starting from 5000. I am using Symfony3 and i want to do it using annotations. For example I have this property
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
I am trying to use the same type of annotations but to generate always the same value. Here are my annotations so far for $money
/**
* @var int
*
* @ORM\Column(name="money", type="integer")
* @ORM\GeneratedValue()
*/
private $money;
My problem is that i dont know what to put between the brackets and even if this is the right way.
Upvotes: 1
Views: 21
Reputation: 1090
This is the best way :
public function __construct()
{
$this->money= 5000;
}
Upvotes: 0
Reputation: 163
Sorry to say but I don't think there is a way to do that with annontations. What you could do is:
/**
* @var int
*
* @ORM\Column(name="money", type="integer")
*/
private $money = 5000;
This way a new user will always have 5000 when created.
Upvotes: 2