Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add function for relation between user and messages
  • Loading branch information
john committed Apr 24, 2017
1 parent 6b910a6 commit 6d9a3d5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/model/User.php
Expand Up @@ -57,6 +57,16 @@ class User {
return null;
}

public static function getByID($user_id) {
$users = User::all();
foreach ($users as $user) {
if ($user->id == $user_id) {
return $user;
}
}
return null;
}

public static function all() {
$dbh = Database::connect();
$stmt = $dbh->prepare("SELECT * from users");
Expand Down Expand Up @@ -102,5 +112,9 @@ class User {

return JWT::encode($data, $key, 'HS512');
}

public function messages() {
return SecureMessage::all_for($this->id);
}
}
?>

0 comments on commit 6d9a3d5

Please sign in to comment.