<?php

namespace App\Console\Commands;

use App\Models\Admin\User;
use App\Models\Project\Budget;
use App\Models\Project\Invoice_main;
use Illuminate\Console\Command;

class DailyReset extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dailty:reset';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $user_list = User::where('status',1)->get();
        foreach ($user_list as $value) {
            if (Date('d') == $value->reset_date) {
                Budget::where('user_id', $value->id)->where('budget_type', 1)->update(['budget_amount' => 0]);
            }
        }
    }
}
