pdo, ['`author_id`=?'], [$this->id]); } public function getPackages() { return Package::search($this->pdo, ['`author_id`=?'], [$this->id]); } public static function hash($password) { return password_hash($password, PASSWORD_DEFAULT, ['cost' => 10]); } protected static function mutator($key, $value) { switch ($key) { case 'password': return self::hash($value); default: return parent::mutator($key, $value); } } public function isAdmin() { return in_array($this->id, Constants::user_admins); } public function verifyPassword($password) { if (!password_verify($password, $this->password)) return false; if (password_needs_rehash( $this->password, PASSWORD_DEFAULT, ['cost' => 10])) $this->password = $password; return true; } }