i need to do a calcul in an entity with symfony (sonata) like : i have 3 labels in my entity with doctrine and i need to save in database a result of : $calcul = $ a + $b ;
here is my entity
class National
{
/**
* @var int
*/
private $id;
/**
* @var string(unique=true)
*/
private $selection;
/**
* @var int
*/
private $a;
/**
* @var int
*/
private $b;
/**
* @var string
*/
private $total;
and this is my classic setter and getter
/**
* Set a
*
* @param string $a
*
* @return Events
*/
public function setA($a)
{
$this->a = $a;
return $this;
}
/**
* Get a
*
* @return string
*/
public function getA()
{
return $this->a;
}
/**
* Set b
*
* @param string $b
* @return Events
*/
public function setB($b)
{
$this->b = $b;
return $this;
}
so the question is how to do the constructor ???
to have the result in $calcul save in the database
(ex: if i write 5 in label $a et 5 in label $b - i need to have 10 write directly in the label $calcul ....)