/home/kueuepay/public_html/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;
    }
}
Journal Details
top
blog

Enhancing Payment Security: The Role of Encryption and Tokenization in Digital Transactions

As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational technologies that are pivotal in this effort are encryption and tokenization.
Encryption is a process that transforms data into a secure format, known as ciphertext, which can only be deciphered using a specific decryption key. This means that even if data is intercepted during transmission, it remains unreadable and protected from unauthorized access. Encryption is essential in safeguarding sensitive payment information, such as credit card details and personal data, during online transactions.
Tokenization, on the other hand, involves substituting sensitive data with unique identifiers or "tokens." These tokens serve as placeholders and have no value outside of the specific transaction context. If intercepted, tokens are meaningless and cannot be used to access the original sensitive data. This method significantly reduces the risk of fraud and data breaches, as the actual payment information is not stored or transmitted.
Together, encryption and tokenization form a powerful security framework. Encryption ensures that data is protected during transmission, while tokenization minimizes the risk of exposing sensitive information by replacing it with secure, non-sensitive tokens.
These technologies are integral to modern payment platforms, providing a robust defense against cyber threats. By implementing advanced encryption and tokenization techniques, businesses can enhance the security of digital transactions, ensuring that users' financial and personal information remains safe. This comprehensive approach not only builds user trust but also fortifies the overall security infrastructure of digital payment systems. As cyber threats evolve, the continued advancement of encryption and tokenization will be crucial in maintaining secure and reliable payment processes.

Tags