<?php

namespace App\Libs\Backoffice\Generic\Actions;


use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;

abstract class BaseAction implements Arrayable, Jsonable
{
    const TYPE_GRID = "grid";
    const TYPE_ROW = "row";

    protected $type = "";
    protected $cssClass = "";
    protected $actionType = "";
    protected $languageKey = "";
    protected $permission = false;
    protected $btnFunction = false;

    public function __construct()
    {

    }

    public function getPermission()
    {
        return $this->permission;
    }

    public function getType()
    {
        return $this->type;
    }

    public function setCssClass($cssClass)
    {
        $this->cssClass = $cssClass;
    }

    public function getCssClass()
    {
        return $this->cssClass;
    }

    public function getLabel()
    {
        return trans($this->languageKey);
    }

    public function setActionType($actionType)
    {
        $this->actionType = $actionType;
    }

    public function getActionType()
    {
        return $this->actionType;
    }

    public function setBtnFunction($btnFunction)
    {
        $this->btnFunction = $btnFunction;
    }

    public function getBtnFunction()
    {
        return $this->btnFunction;
    }

    public function toArray()
    {
        return array(
            "type" => $this->getType(),
            "cssClass" => $this->getCssClass(),
            "actionType" => $this->getActionType(),
            "label" => $this->getLabel(),
            "btnFunction" => $this->getBtnFunction()
        );
    }

    public function toJson($options = 0)
    {
        return json_encode($this->toArray(), $options);
    }

}


