<?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);
}
}
Contact Section
We’d love to hear from you! Whether you have questions, feedback, or need support, our team is here to help. Reach out to us via email, phone, or visit our office. We’re committed to providing you with exceptional service and ensuring your experience with NFC Pay is seamless and satisfying. Let’s connect!