Improve error message for people trying to log in to the Patrons Circle

This commit is contained in:
Alex Cabal 2024-12-13 10:10:07 -06:00
parent 95d1b9e02e
commit cf5f488cae
9 changed files with 104 additions and 11 deletions

View file

@ -11,6 +11,7 @@ use function Safe\preg_match;
* @property string $Url
* @property ?Patron $Patron
* @property ?NewsletterSubscription $NewsletterSubscription
* @property ?Payment $LastPayment
*/
class User{
use Traits\Accessor;
@ -27,6 +28,7 @@ class User{
protected bool $_IsRegistered;
/** @var array<Payment> $_Payments */
protected array $_Payments;
protected ?Payment $_LastPayment;
protected Benefits $_Benefits;
protected string $_Url;
protected ?Patron $_Patron;
@ -87,6 +89,20 @@ class User{
return $this->_Payments;
}
protected function GetLastPayment(): ?Payment{
if(!isset($this->_LastPayment)){
$this->_LastPayment = Db::Query('
SELECT *
from Payments
where UserId = ?
order by Created desc
limit 1
', [$this->UserId], Payment::class)[0] ?? null;
}
return $this->_LastPayment;
}
protected function GetBenefits(): Benefits{
if(!isset($this->_Benefits)){
if(isset($this->UserId)){