diff --git a/Provider.php b/Provider.php index 6987029..2d8e8ae 100644 --- a/Provider.php +++ b/Provider.php @@ -4,6 +4,7 @@ use MapasCulturais\Entities; use MapasCulturais\Entities\Agent; use MapasCulturais\i; +use DateTime; use Mustache\Mustache; use Respect\Validation\Validator; @@ -335,6 +336,14 @@ protected function _init() { $login = $app->auth->doLogin(); if ($login['success']) { + $entity = $app->user->profile; + + if($entity->dataDeNascimento){ + $today = new DateTime('now'); + $calc = (new DateTime($entity->dataDeNascimento))->diff($today); + $entity->idoso = ($calc->y >= 60) ? "1" : "0"; + $entity->save(true); + } $this->json([ 'error' => false, 'redirectTo' => $app->auth->getRedirectPath()