<?php

namespace App\Console\Commands;

use App\Models\UserCoin;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use App\Models\User;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'For delete Free Coin';

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

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $currentDate = Carbon::now()->today()->toDateString();

        //To get single notification message with date and time...
        $data = UserCoin::where('free_stock_end', $currentDate)->first();
        $data->free_stock_qty = 0;
        $data->save();
    }

}
