/home/kueuepay/www/app/Models/Admin/Currency.php
<?php

namespace App\Models\Admin;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Currency extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $appends = [
        'both',
        'senderCurrency',
        'receiverCurrency',
        'editData',
    ];

    protected $casts = [
        'admin_id' => 'integer',
        'country'  => 'string',
        'name'     => 'string',
        'code'     => 'string',
        'symbol'   => 'string',
        'flag'     => 'string',
        'rate'     => 'decimal:16',
        'sender'   => 'integer',
        'receiver' => 'integer',
        'default'  => 'integer',
        'status'   => 'integer',
        'created_at' => 'date:Y-m-d',
        'updated_at' => 'date:Y-m-d',
    ];

    public function getBothAttribute() {
        if($this->sender == true && $this->receiver == true) {
            return true;
        }
        return false;
    }

    public function getSenderCurrencyAttribute() {
        if($this->sender == true) {
            return true;
        }
        return false;
    }

    public function getReceiverCurrencyAttribute() {
        if($this->receiver == true) {
            return true;
        }
        return false;
    }

    public function getEditDataAttribute() {
        $role = "";
        if($this->sender == true && $this->receiver == true) {
            $role = "both";
        }else if($this->sender == true && $this->receiver == false) {
            $role = "sender";
        }else if($this->receiver == true && $this->sender == false) {
            $role = "receiver";
        }
        $data = [
            'name'      => $this->name,
            'code'      => $this->code,
            'flag'      => $this->flag,
            'role'      => $role,
            'option'    => ($this->default == true) ? 1 : 0,
            'symbol'    => $this->symbol,
            'type'      => $this->type,
            'rate'      => get_amount($this->rate),
            'country'   => $this->country,
        ];

        return json_encode($data);
    }


    public function scopeDefault() {
        return $this->where('default',true)->first() ?? false;
    }


    public function isDefault() {
        if($this->default == true) return true;
        return false;
    }

    public function scopeSearch($query,$text) {
        $query->where(function($q) use ($text) {
            $q->where("country","like","%".$text."%");
        })->orWhere("name","like","%".$text."%")->orWhere("code","like","%".$text."%");
    }

    public function scopeActive($query) {
        return $query->where("status",true);
    }

    public function scopeSender($query) {
        return $query->where("sender",true);
    }

    public function scopeReceiver($query) {
        return $query->where("receiver",true);
    }

    public function scopeRoleBoth($query) {
        return $query->where("sender",true)->where('receiver',true);
    }

    public function scopeRoleHasOne($query) {
        return $query->where(function($q) {
            $q->where('sender',true);
        })->orWhere('receiver',true);
    }

    public function getCurrencyCodeAttribute() {
        return $this->code;
    }
}
About
top

About NFC Pay: Our Story and Mission

NFC Pay was founded with a vision to transform the way people handle transactions. Our journey is defined by a commitment to innovation, security, and convenience. We strive to deliver seamless, user-friendly payment solutions that make everyday transactions effortless and secure. Our mission is to empower you to pay with ease and confidence, anytime, anywhere.

  • Simplifying Payments, One Tap at a Time.
  • Reinventing Your Wallet for Modern Convenience.
  • Smart Payments for a Effortless Lifestyle.
  • Experience the Ease of Tap and Pay.
  • Innovative Solutions for Your Daily Transactions.

Frequently Asked Questions About NFC Pay

Here are answers to some common questions about NFC Pay. We aim to provide clear and concise information to help you understand how our platform works and how it can benefit you. If you have any further inquiries, please don’t hesitate to contact our support team.

faq-img

How do I register for NFC Pay?

Download the app and sign up using your email or phone number, then complete the verification process.

Is my payment information secure?

Yes, we use advanced encryption and security protocols to protect your payment details.

Can I add multiple cards to my NFC Pay wallet?

Absolutely, you can link multiple debit or credit cards to your wallet.

How do I transfer money to another user?

Go to the transfer section, select the recipient, enter the amount, and authorize the transfer.

What should I do if I forget my PIN?

Use the “Forgot PIN” feature in the app to reset it following the provided instructions.

How can I activate my merchant account?

Sign up for a merchant account through the app and follow the setup instructions to start accepting payments.

Can I track my payment status?

Yes, you can view and track your payment status in the account dashboard