File: /var/www/vhost/disk-apps/qas.sports-crowd.com/app/Console/Commands/UpdateAgeAcademyUsersCommand.php
<?php
namespace App\Console\Commands;
use App\AcademyUser;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class UpdateAgeAcademyUsersCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sportscrowd:updateAgeAcademyUsers';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Proceso encargado de actualizar la edad de los usuarios de la academia';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
AcademyUser::whereMonth('birthdate', now()->month)
->whereDay('birthdate', now()->day)
->update(['age' => DB::raw('TIMESTAMPDIFF(YEAR, birthdate, CURDATE())')]);
}
}