38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
// <?php
|
|
|
|
// namespace App\Console\Commands;
|
|
|
|
// use Illuminate\Console\Command;
|
|
// use App\Models\DailyStepsCount;
|
|
// use App\Models\User;
|
|
// use Carbon\Carbon;
|
|
// use App\Models\LeaderboardMaster;
|
|
|
|
// class StepsCountPoint extends Command
|
|
// {
|
|
// protected $signature = 'steps:count';
|
|
// protected $description = 'Calculate points based on daily step counts.';
|
|
// public function handle()
|
|
// {
|
|
// $date = Carbon::now()->toDateString();
|
|
// $dailyStepCount = DailyStepsCount::where('date',$date)->get();
|
|
|
|
// if($dailyStepCount){
|
|
// foreach($dailyStepCount as $count){
|
|
|
|
// $steps = $count->step_count;
|
|
// $points = intval(floor($steps/1000));
|
|
// $user_id = $count->user_id;
|
|
// $leaderboardMaster = LeaderboardMaster::where('user_id', $user_id)->first();
|
|
// if ($leaderboardMaster) {
|
|
|
|
// $leaderboardMaster->total_score += $points;
|
|
// $leaderboardMaster->save();
|
|
// }
|
|
|
|
// }
|
|
// $this->info('Points Added Successfully');
|
|
// }
|
|
// }
|
|
// }
|