<?php

namespace App\Console\Commands;

use App\Models\Mail;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;

class MarkTimeoutMail extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:mark-timeout-mail';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '标记超时未读邮件';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        //
        Mail::where([
            ['created_at', "<=", Carbon::now()->subSeconds(300)],
            ['is_read', '=', 0],
        ])->update([
            'is_read' => 1,
        ]);
    }
}
