<?php


namespace App\Jobs;

use Illuminate\Support\Facades\Artisan;

class PropertyCatalogServiceJob extends Job
{
    protected $propertyId;
    protected $language;
    protected $email;

    /**
     * Create a new job instance.
     */
    public function __construct($propertyId, $language, $email = null)
    {
        $this->propertyId = $propertyId;
        $this->language = $language;
        $this->email = $email;
    }

    /**
     * Execute the job.
     */
    public function handle()
    {
        chdir(base_path());

        Artisan::call('cron:property-catalog-service', [
            'property_id' => $this->propertyId,
            'language' => $this->language,
            '--email' => $this->email,
        ]);
    }
}
