From 104264607bc135a0246428f0654b53603f2d4199 Mon Sep 17 00:00:00 2001 From: Joshua Dwire Date: Tue, 10 May 2016 19:17:55 -0400 Subject: [PATCH] Pad last 4 card digits to a string of length 4, since we're storing it as an int --- app/Models/PaymentMethod.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php index 62072dca09..07c6d2e19e 100644 --- a/app/Models/PaymentMethod.php +++ b/app/Models/PaymentMethod.php @@ -71,6 +71,11 @@ class PaymentMethod extends EntityModel return static::lookupBankData($this->routing_number); } + public function getLast4Attribute($value) + { + return $value ? str_pad($value, 4, '0', STR_PAD_LEFT) : null; + } + public function scopeScope($query, $publicId = false, $accountId = false, $accountGatewayTokenId = false) { $query = parent::scopeScope($query, $publicId, $accountId);