mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 23:00:28 -04:00
Use static class names instead of strings when getting objects from the DB
This commit is contained in:
parent
a442f92e28
commit
acb6b2949f
16 changed files with 36 additions and 34 deletions
10
lib/User.php
10
lib/User.php
|
@ -38,7 +38,7 @@ class User{
|
|||
from Payments
|
||||
where UserId = ?
|
||||
order by Created desc
|
||||
', [$this->UserId], 'Payment');
|
||||
', [$this->UserId], Payment::class);
|
||||
}
|
||||
|
||||
return $this->_Payments;
|
||||
|
@ -50,7 +50,7 @@ class User{
|
|||
SELECT *
|
||||
from Benefits
|
||||
where UserId = ?
|
||||
', [$this->UserId], 'Benefits');
|
||||
', [$this->UserId], Benefits::class);
|
||||
|
||||
if(sizeof($result) == 0){
|
||||
$this->_Benefits = new Benefits();
|
||||
|
@ -129,7 +129,7 @@ class User{
|
|||
SELECT *
|
||||
from Users
|
||||
where UserId = ?
|
||||
', [$userId], 'User');
|
||||
', [$userId], User::class);
|
||||
|
||||
return $result[0] ?? throw new Exceptions\UserNotFoundException();
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class User{
|
|||
SELECT *
|
||||
from Users
|
||||
where Email = ?
|
||||
', [$email], 'User');
|
||||
', [$email], User::class);
|
||||
|
||||
return $result[0] ?? throw new Exceptions\UserNotFoundException();
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class User{
|
|||
inner join Benefits using (UserId)
|
||||
where u.Email = ?
|
||||
or u.Uuid = ?
|
||||
', [$identifier, $identifier], 'User');
|
||||
', [$identifier, $identifier], User::class);
|
||||
|
||||
if(sizeof($result) == 0){
|
||||
throw new Exceptions\UserNotFoundException();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue