<?php

namespace App\Http\ViewComposer;

use App\Models\ApiSettings;
use Illuminate\View\View;

class ReCaptchaComposer
{
    public $reCaptcha;

    public function __construct()
    {
        $this->reCaptcha = ApiSettings::where('domain_holder', '=', ApiSettings::DOMAIN_HOLDER['recaptcha_api'])->first();
    }

    public function compose(View $view)
    {
        $view->with('reCaptcha', $this->reCaptcha);
    }

    public function validate()
    {
        if ($this->reCaptcha->status === ApiSettings::ENABLE) {
            return 'required|captcha';
        }
        return [];
    }
}
