hasOne(Customer::class, 'id', 'customer_id'); } public function displayName(){ $parsed = json_decode($this->detail_json); if(!@$parsed->card){ return "Card ending in {$this->card_last_four}"; } return "{$parsed->card->brand} ending in {$parsed->card->last4}, expiring {$parsed->card->exp_month} / {$parsed->card->exp_year}"; } }