Skip to content
Permalink
Browse files

Add function for relation between user and messages

  • Loading branch information
john committed Apr 24, 2017
1 parent 6b910a6 commit 6d9a3d511c15157afa882049a45d8d12efce585e
Showing with 14 additions and 0 deletions.
  1. +14 −0 app/model/User.php
@@ -57,6 +57,16 @@ public static function get($username) {
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");
@@ -102,5 +112,9 @@ public function token() {
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.
You can’t perform that action at this time.