Skip to content

Commit

Permalink
Atualiza campo de pessoa idosa no momento do login Ref.: #70
Browse files Browse the repository at this point in the history
  • Loading branch information
LimaSystem committed Feb 5, 2024
1 parent 3743030 commit a299fce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use MapasCulturais\Entities;
use MapasCulturais\Entities\Agent;
use MapasCulturais\i;
use DateTime;
use Mustache\Mustache;
use Respect\Validation\Validator;

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a299fce

Please sign in to comment.