<?php

namespace App\View\Components;

use Illuminate\View\Component;
use App\Models\Especiality;

class AreaForm extends Component
{
    private  const URL_CREATE_AREA = '/admin/create-areas';
    private  const URL_UPDATE_AREA = '/admin/update-areas';
    private  const NAME_FORM = "Especiality";
    public $especiality;
    public $action = self::URL_CREATE_AREA;
    public $name = self::NAME_FORM;
    public $new;
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(Especiality $especiality, $isUpdate = false)
    {
        $this->especiality = $especiality;
        $this->new = (!$isUpdate);
        if($isUpdate)
            $this->action =  self::URL_UPDATE_AREA;
    }

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