diff options
Diffstat (limited to 'classes/Offer.php')
-rw-r--r-- | classes/Offer.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/classes/Offer.php b/classes/Offer.php index 815f626..8fa9ba7 100644 --- a/classes/Offer.php +++ b/classes/Offer.php @@ -27,7 +27,7 @@ class Offer extends Model{ public $table = 'offer', - $fillable_columns = ['contactId', 'start_date', 'end_date', 'invoice_date', 'accepted', 'invoice_fileId']; + $fillable_columns = ['contactId', 'start_date', 'end_date', 'invoice_date', 'accepted', 'invoice_fileId', 'payment_key']; protected function accessor($key, $value) { switch ($key) { @@ -57,6 +57,25 @@ class Offer extends Model{ } /** + * A random max-63-char string that can be used as payment_key + * + * @return string The random string + */ + public static function getRandomPaymentKey() { + return preg_replace('/[^\w]+/', '', + base64_encode(openssl_random_pseudo_bytes(45))); + } + + /** + * Get whether the offer is eligible for online payment or not + * + * @return bool True iff it is eligible + */ + public function getPaymentEligibility() { + return $this->payment_key != ''; + } + + /** * Get the contact that this offer is linked to * * @return contact The contact |