<?php

namespace App\View\Components;

use Illuminate\View\Component;

class PaymentMethodForm extends Component
{
    private  const URL_CREATE = '/admin/create-payments-method';
    private  const URL_UPDATE = '/admin/update-payments-method';
    private  const NAME_FORM = "PaymentMethod";
    public $action = self::URL_CREATE;
    public $name = self::NAME_FORM;
    public $new;
    public $redirectToCreatePayment;
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($isUpdate = false, $redirectToCreatePayment = false)
    {
        $this->new = (!$isUpdate);
        $this->redirectToCreatePayment = $redirectToCreatePayment;
        if($isUpdate)
            $this->action =  self::URL_UPDATE;
    }


    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return view('components.payment-method-form',[
            "name"=>$this->name,
            "action"=>$this->action,
            "id"=>$this->name,
            "new"=>$this->new,
            "redirectToCreatePayment"=>$this->redirectToCreatePayment
        ]);
    }
}
