<?php

namespace App\Helpers\Customer;

use App\Models\Customer\PointModel;

class PointHelper extends CustomerHelper
{
    public function __construct()
    {
        parent::__construct();
        $this->setTitleField(field: PointModel::TITLE);
    }

    public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
    {
        switch ($field) {
            default:
                if (in_array($field, $viewDatas['control']['actionFilters'])) {
                    $value = array_key_exists($value, $viewDatas['control']['filter_optons'][$field]) ? $viewDatas['control']['filter_optons'][$field][$value]->getTitle() : "";
                }
                break;
        }
        if (is_array($value)) {
            echo __METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다";
            exit;
        }
        return $value;
    }
    public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
    {
        switch ($action) {
            case 'modify':
                $action = $viewDatas['entity']->getPK();
                break;
            case 'delete':
                $action = "";
                break;
            default:
                $action = parent::getListButton($action, $label, $viewDatas, $extras);
                break;
        }
        return $action;
    }
}
