<?php

namespace App\Console\Commands;

use Carbon\Carbon;
use Codexshaper\WooCommerce\Facades\Product;
use Illuminate\Console\Command;
use App\Setting;
use App\Article;
use App\Mylog;
use App\Stock;
use Codexshaper\WooCommerce\Models\Product as ModelsProduct;
use Codexshaper\WooCommerce\Facades\Variation;
use Codexshaper\WooCommerce\Facades\Category;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\DB;


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

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

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

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        try {
            $log = "*** STARTDAY: ";
            
            // Select all the fields of the Stock table        

        } catch (\Exception $e) {
            $log .= $e->getMessage();
            echo "Error: " . $e->getMessage();
        }

        echo $log;

        Log::channel('testpao')->notice($log);

        if (true) {
            // Send the email 
            Mail::raw($log, function ($message) {
                $message->to(Mylog::getEmail());
                $message->subject(Mylog::getSubjectEmail("STARTDAY"));
            });
        }
    }
}
