/home/kueuepay/public_html/app/Models/Card.php
<?php

namespace App\Models;

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

class Card extends Model
{
    use HasFactory;

    protected $guarded = ['id'];

    protected $casts    = [
        'id'            => 'integer',
        'user_id'       => 'integer',
        'card_number_hash'=> 'string',
        'slug'          => 'string',
        'name'          => 'string',
        'type'          => 'string',
        'card_number'   => 'string',
        'card_cvc'      => 'string',
        'expiry_date'   => 'string',
        'default'       => 'integer',
        'created_at'    => 'datetime',
        'updated_at'    => 'datetime',  
    ];

    //auth relation
    public function scopeAuth($query){
        return $query->where('user_id',auth()->user()->id);
    }

    //search
    public function scopeSearch($query,$data) {
        return $query->where("name",'LIKE','%'.$data.'%')
                     ->orWhere("card_number",'LIKE','%'.$data.'%')
                     ->orderBy('id','desc');
    }

    //user table relation
    public function user(){
        return $this->belongsTo(User::class);
    }

    //transaction table relation
    public function transactions(){
        return $this->hasMany(Transaction::class);
    }
}
Web Journal
top

Discover the Latest in Digital Payments and NFC Technology

Dive into our blog to explore the cutting-edge trends in digital payments and NFC technology. Stay updated on the innovations that are revolutionizing transactions, boosting security, and making payments quicker and more convenient. Learn how these advancements are shaping the future of financial interactions and driving the global transition towards a cashless world.

The Rise of Contactless Payments:...

In recent years, contactless payments have surged in popularity, driven...

Enhancing Payment Security: The Role...

As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational...

The Future of Digital Wallets:...

Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly...