From a012ea9e7d5dd0baadb549e1460a8339224f37a5 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 14 May 2015 11:18:12 +0200 Subject: Own Model class; new namespaces Database and Controllers; RFC2822 dates --- src/CamilStaps/BotleaguesApi/Bot.php | 11 ---- src/CamilStaps/BotleaguesApi/Competition.php | 12 ---- src/CamilStaps/BotleaguesApi/CompetitionType.php | 13 ---- src/CamilStaps/BotleaguesApi/Database/Bot.php | 9 +++ .../BotleaguesApi/Database/Competition.php | 10 +++ .../BotleaguesApi/Database/CompetitionType.php | 11 ++++ src/CamilStaps/BotleaguesApi/Database/Game.php | 9 +++ src/CamilStaps/BotleaguesApi/Database/Model.php | 30 +++++++++ .../BotleaguesApi/Database/Participant.php | 10 +++ .../BotleaguesApi/Database/PasswordReminder.php | 38 +++++++++++ src/CamilStaps/BotleaguesApi/Database/User.php | 75 +++++++++++++++++++++ .../BotleaguesApi/Database/UserToken.php | 24 +++++++ src/CamilStaps/BotleaguesApi/Game.php | 11 ---- src/CamilStaps/BotleaguesApi/Participant.php | 12 ---- src/CamilStaps/BotleaguesApi/PasswordReminder.php | 40 ------------ src/CamilStaps/BotleaguesApi/User.php | 76 ---------------------- src/CamilStaps/BotleaguesApi/UserToken.php | 21 ------ 17 files changed, 216 insertions(+), 196 deletions(-) delete mode 100644 src/CamilStaps/BotleaguesApi/Bot.php delete mode 100644 src/CamilStaps/BotleaguesApi/Competition.php delete mode 100644 src/CamilStaps/BotleaguesApi/CompetitionType.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/Bot.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/Competition.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/CompetitionType.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/Game.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/Model.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/Participant.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/PasswordReminder.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/User.php create mode 100644 src/CamilStaps/BotleaguesApi/Database/UserToken.php delete mode 100644 src/CamilStaps/BotleaguesApi/Game.php delete mode 100644 src/CamilStaps/BotleaguesApi/Participant.php delete mode 100644 src/CamilStaps/BotleaguesApi/PasswordReminder.php delete mode 100644 src/CamilStaps/BotleaguesApi/User.php delete mode 100644 src/CamilStaps/BotleaguesApi/UserToken.php (limited to 'src/CamilStaps/BotleaguesApi') diff --git a/src/CamilStaps/BotleaguesApi/Bot.php b/src/CamilStaps/BotleaguesApi/Bot.php deleted file mode 100644 index 04fa2c7..0000000 --- a/src/CamilStaps/BotleaguesApi/Bot.php +++ /dev/null @@ -1,11 +0,0 @@ -format($this->date_format); + } + + public function getCreatedAtAttribute($attr) { + return $this->formatDate($attr); + } + + public function getUpdatedAtAttribute($attr) { + return $this->formatDate($attr); + } + +} \ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/Database/Participant.php b/src/CamilStaps/BotleaguesApi/Database/Participant.php new file mode 100644 index 0000000..584d00c --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Database/Participant.php @@ -0,0 +1,10 @@ +valid_till = date("Y-m-d H:i:s", time() + 3600); + + $user = User::find($this->userId); + Mail::send('packages.camil-staps.botleagues-api.emails.auth.reminder', ['token' => $this->token], function($message) use ($user) { + $message->to($user->email, "User " . $user->id); + }); + + return parent::save($options); + } + + /** + * Disable updated_at timestamp + */ + public function setUpdatedAtAttribute($value) {} + +} \ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/Database/User.php b/src/CamilStaps/BotleaguesApi/Database/User.php new file mode 100644 index 0000000..383cc38 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Database/User.php @@ -0,0 +1,75 @@ +isAdministrator; + } + + public function validToken($token) { + return UserToken::where('userId', $this->id)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->count() > 0; + } + + /** + * Get the unique identifier for the user. + * + * @return mixed + */ + public function getAuthIdentifier() { + return $this->getKey(); + } + + /** + * Get the password for the user. + * @todo not implemented yet + * @return string + */ + public function getAuthPassword() { + return $this->password; + } + + /** + * Get the token value for the "remember me" session. + * @todo not implemented yet + * @return string + */ + public function getRememberToken() { + return null; + } + + /** + * Set the token value for the "remember me" session. + * @todo not implemented yet + * @param string $value + * @return void + */ + public function setRememberToken($value) { + return null; + } + + /** + * Get the column name for the "remember me" token. + * @todo not implemented yet + * @return string + */ + public function getRememberTokenName() { + return null; + } + + /** + * Get the e-mail address where password reminders are sent. + * + * @return string + */ + public function getReminderEmail() { + return $this->email; + } +} \ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/Database/UserToken.php b/src/CamilStaps/BotleaguesApi/Database/UserToken.php new file mode 100644 index 0000000..92b03b8 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Database/UserToken.php @@ -0,0 +1,24 @@ +valid_till = date("Y-m-d H:i:s", time() + 3600); + + return parent::save($options); + } + + public function getValidTillAttribute($attr) { + return $this->formatDate($attr); + } + +} \ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/Game.php b/src/CamilStaps/BotleaguesApi/Game.php deleted file mode 100644 index 3823ab2..0000000 --- a/src/CamilStaps/BotleaguesApi/Game.php +++ /dev/null @@ -1,11 +0,0 @@ -valid_till = date("Y-m-d H:i:s", time() + 3600); - - $user = User::find($this->userId); - Mail::send('packages.camil-staps.botleagues-api.emails.auth.reminder', ['token' => $this->token], function($message) use ($user) { - $message->to($user->email, "User " . $user->id); - }); - - return parent::save($options); - } - - /** - * Disable updated_at timestamp - */ - public function setUpdatedAtAttribute($value) {} - -} \ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/User.php b/src/CamilStaps/BotleaguesApi/User.php deleted file mode 100644 index 560f737..0000000 --- a/src/CamilStaps/BotleaguesApi/User.php +++ /dev/null @@ -1,76 +0,0 @@ -isAdministrator; - } - - public function validToken($token) { - return UserToken::where('userId', $this->id)->where('token', $token)->where('valid_till', '>', date("Y-m-d H:i:s"))->count() > 0; - } - - /** - * Get the unique identifier for the user. - * - * @return mixed - */ - public function getAuthIdentifier() { - return $this->getKey(); - } - - /** - * Get the password for the user. - * @todo not implemented yet - * @return string - */ - public function getAuthPassword() { - return $this->password; - } - - /** - * Get the token value for the "remember me" session. - * @todo not implemented yet - * @return string - */ - public function getRememberToken() { - return null; - } - - /** - * Set the token value for the "remember me" session. - * @todo not implemented yet - * @param string $value - * @return void - */ - public function setRememberToken($value) { - return null; - } - - /** - * Get the column name for the "remember me" token. - * @todo not implemented yet - * @return string - */ - public function getRememberTokenName() { - return null; - } - - /** - * Get the e-mail address where password reminders are sent. - * - * @return string - */ - public function getReminderEmail() { - return $this->email; - } -} \ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/UserToken.php b/src/CamilStaps/BotleaguesApi/UserToken.php deleted file mode 100644 index 9909f6a..0000000 --- a/src/CamilStaps/BotleaguesApi/UserToken.php +++ /dev/null @@ -1,21 +0,0 @@ -valid_till = date("Y-m-d H:i:s", time() + 3600); - - return parent::save($options); - } - -} \ No newline at end of file -- cgit v1.2.3