<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MetodoPagamento extends \App\Models\AbstractModels\AbstractMetodoPagamento
{
    // Tipi di pagamento
    const CARTA_DI_CREDITO = 'carta_di_credito';
    const CARTA_DI_DEBITO = 'carta_di_debito';
    const BONIFICO = 'bonifico';
    const PAYPAL = 'paypal';
    const STRIPE = 'stripe';
    const CONTANTI = 'contanti';
    const CREDITO = 'credito';
    const APPLE_PAY = 'apple_pay';
    const GOOGLE_PAY = 'google_pay';
    const CUPON = 'cupon';
    const SEGRESTA_WALLET = 'segresta_wallet';
    const POS = 'pos';
    const STAFF = 'staff';


    public static function getTipiPagamento()
    {
        return collect([
            // self::APPLE_PAY => [
            //     'label' => 'Apple Pay',
            //     'value' => self::APPLE_PAY,
            //     'icon' => 'bx-mobile',
            // ],
            // self::BONIFICO => [
            //     'label' => 'Bonifico',
            //     'value' => self::BONIFICO,
            //     'icon' => 'bx-transfer',
            // ],
            // self::CARTA_DI_CREDITO => [
            //     'label' => 'Carta di credito',
            //     'value' => self::CARTA_DI_CREDITO,
            //     'icon' => 'bx-credit-card',
            // ],
            // self::CARTA_DI_DEBITO => [
            //     'label' => 'Carta di debito',
            //     'value' => self::CARTA_DI_DEBITO,
            //     'icon' => 'bx-credit-card',
            // ],
            self::CONTANTI => [
                'label' => 'Contanti',
                'value' => self::CONTANTI,
                'icon' => 'bx-money',
            ],
            // self::CREDITO => [
            //     'label' => 'Credito',
            //     'value' => self::CREDITO,
            //     'icon' => 'bx-wallet',
            // ],
            self::CUPON => [
                'label' => 'Cupon',
                'value' => self::CUPON,
                'icon' => 'bx-purchase-tag',
            ],
            // self::GOOGLE_PAY => [
            //     'label' => 'Google Pay',
            //     'value' => self::GOOGLE_PAY,
            //     'icon' => 'bx-mobile',
            // ],
            // self::PAYPAL => [
            //     'label' => 'Paypal',
            //     'value' => self::PAYPAL,
            //     'icon' => 'bxl-paypal',
            // ],
            self::POS => [
                'label' => 'POS',
                'value' => self::POS,
                'icon' => 'bx-credit-card',
            ],
            self::SEGRESTA_WALLET => [
                'label' => 'Segresta Wallet',
                'value' => self::SEGRESTA_WALLET,
                'icon' => 'bx-wallet',
            ],
            self::STAFF => [
                'label' => 'Staff',
                'value' => self::STAFF,
                'icon' => 'bx-user',
            ],
            // self::STRIPE => [
            //     'label' => 'Stripe',
            //     'value' => self::STRIPE,
            //     'icon' => 'bx-credit-card',
            // ],
       
        ]);
    }

    public function getIcona()
    {
        $tipo = (string) ($this->tipo ?? '');
        $match = self::getTipiPagamento()->firstWhere('value', $tipo);

        if (!is_array($match)) {
            return 'bx-wallet';
        }

        return $match['icon'] ?? 'bx-wallet';
    }
}
