<?php

namespace App\Models;

class PaymentMethod extends Model
{
    protected $table = 'payment_method';

    public function customer(){
        return $this->hasOne(Customer::class, 'id', 'customer_id');
    }

    public function displayName(){
        $parsed = json_decode($this->detail_json);
        return "<b>{$parsed->card->brand}</b> ending in <b>{$parsed->card->last4}</b>, expiring {$parsed->card->exp_month} / {$parsed->card->exp_year}";
    }
}
