<?php

namespace App\Console\Commands;

use App\Models\Ad;
use Illuminate\Console\Command;

class SendAdPostedEmail extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'send:send_ad_posted_email {--uri=} {--uri2=} {--uri3=} {--uri4=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send Ad Posted Email';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $subject = urldecode($this->option("uri"));
        $to =  urldecode($this->option("uri2"));
        $name = urldecode($this->option("uri3"));
        $ad_id = urldecode($this->option("uri4"));
        $ad = Ad::find($ad_id);
        $mailbody = view('email_templates.adsuccess', compact('name','ad'))->render();
        send_email($to, $subject, $mailbody);
    }
}
