I have a question about best practices in CakePHP!
Let's imagine the following situation:
In a Receipt Model i have the code:
public function beforeValidate()
{
$this->data[$this->name]["client_id"] = CakeSession::read("Auth.User.id");
$this->data[$this->name]["date"] = date('Y-m-d H:i:s');
$receipt = $this->data[$this->name]["receipt"];
$cod_filial = substr($receipt, 0, 3);
$qtdade_cupom = substr($receipt, 12, 2);
$tipo_pagamento = substr($receipt, 14, 1);
$this->data[$this->name]["cod"] = $cod_filial;
$this->data[$this->name]["quantity"] = $qtdade_cupom;
$this->data[$this->name]["payment_type"] = $tipo_pagamento;
$this->data[$this->name]["is_valid"] = null;
return true;
}
I have to do a lot of verifications with the variables $qtdade_cupom, $cod_filial like check the valid digit.
Where do I do the maths??
I create a method inside the model like
public function checkDigits()
OR
I create a Behaviour to do this?
OR
Other solution??