diff options
Diffstat (limited to 'src/CamilStaps')
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Bot.php | 3 | ||||
-rw-r--r-- | src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php | 19 | ||||
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Competition.php | 12 | ||||
-rw-r--r-- | src/CamilStaps/BotleaguesApi/CompetitionType.php | 13 | ||||
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Game.php | 11 | ||||
-rw-r--r-- | src/CamilStaps/BotleaguesApi/Participant.php | 12 | ||||
-rw-r--r-- | src/CamilStaps/BotleaguesApi/User.php | 4 |
7 files changed, 70 insertions, 4 deletions
diff --git a/src/CamilStaps/BotleaguesApi/Bot.php b/src/CamilStaps/BotleaguesApi/Bot.php index f45ada7..04fa2c7 100644 --- a/src/CamilStaps/BotleaguesApi/Bot.php +++ b/src/CamilStaps/BotleaguesApi/Bot.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model; class Bot extends Model { - + protected $table = 'bots'; + protected $fillable = ['userId', 'gameId', 'title']; }
\ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php index 012b5cf..22ec44c 100644 --- a/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php +++ b/src/CamilStaps/BotleaguesApi/BotleaguesApiServiceProvider.php @@ -4,6 +4,7 @@ namespace CamilStaps\BotleaguesApi; use \Illuminate\Database\Eloquent\ModelNotFoundException; use \Illuminate\Support\ServiceProvider; use \Illuminate\Support\Facades\App; +use \Illuminate\Support\Facades\Config; use \Dingo\Api\Facade\API; use Response; @@ -27,15 +28,27 @@ class BotleaguesApiServiceProvider extends ServiceProvider { include __DIR__ . '/../../filters.php'; include __DIR__ . '/../../routes.php'; + + App::fatal(function($e) { + return Response::make( + ['error' => Config::get('app.debug') ? $e->getMessage() : "Internal error"], + 500); + }); API::error(function(ModelNotFoundException $e) { - return Response::make(['error' => 'Resource not found'], 404); + return Response::make( + ['error' => 'Resource not found'], + 404); }); API::error(function(\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException $e) { - return Response::make(['error' => $e->getMessage() == null ? 'Access denied' : $e->getMessage()], 404); + return Response::make( + ['error' => !Config::get('app.debug') || empty($e->getMessage()) ? 'Access denied' : $e->getMessage()], + 404); }); API::error(function(\Exception $e) { - return Response::make(['error' => $e->getMessage()], 500); + return Response::make( + ['error' => Config::get('app.debug') ? $e->getMessage() : "Internal error"], + 500); }); } diff --git a/src/CamilStaps/BotleaguesApi/Competition.php b/src/CamilStaps/BotleaguesApi/Competition.php new file mode 100644 index 0000000..a8da665 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Competition.php @@ -0,0 +1,12 @@ +<?php +namespace CamilStaps\BotleaguesApi; + +use Illuminate\Database\Eloquent\Model; + +class Competition extends Model { + + protected $table = 'competitions'; + protected $hidden = []; + protected $fillable = ['gameId', 'title', 'description', 'competition_type', 'start', 'end', 'max_players']; + +}
\ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/CompetitionType.php b/src/CamilStaps/BotleaguesApi/CompetitionType.php new file mode 100644 index 0000000..b9fb426 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/CompetitionType.php @@ -0,0 +1,13 @@ +<?php +namespace CamilStaps\BotleaguesApi; + +use Illuminate\Database\Eloquent\Model; + +class CompetitionType extends Model { + + protected $table = 'competition_types'; + protected $primaryKey = 'type'; + protected $hidden = []; + protected $fillable = ['description', 'explanation']; + +}
\ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/Game.php b/src/CamilStaps/BotleaguesApi/Game.php new file mode 100644 index 0000000..3823ab2 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Game.php @@ -0,0 +1,11 @@ +<?php +namespace CamilStaps\BotleaguesApi; + +use Illuminate\Database\Eloquent\Model; + +class Game extends Model { + + protected $table = 'games'; + protected $fillable = ['title']; + +}
\ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/Participant.php b/src/CamilStaps/BotleaguesApi/Participant.php new file mode 100644 index 0000000..65e1261 --- /dev/null +++ b/src/CamilStaps/BotleaguesApi/Participant.php @@ -0,0 +1,12 @@ +<?php +namespace CamilStaps\BotleaguesApi; + +use Illuminate\Database\Eloquent\Model; + +class Participant extends Model { + + protected $table = 'competition_types'; + protected $hidden = []; + protected $fillable = ['botId', 'competitionId']; + +}
\ No newline at end of file diff --git a/src/CamilStaps/BotleaguesApi/User.php b/src/CamilStaps/BotleaguesApi/User.php index 849ae83..161d285 100644 --- a/src/CamilStaps/BotleaguesApi/User.php +++ b/src/CamilStaps/BotleaguesApi/User.php @@ -9,4 +9,8 @@ class User extends Model { protected $hidden = ['password', 'remember_token', 'api_key']; protected $fillable = ['email', 'password']; + public function isAdministrator() { + return (bool) $this->isAdministrator; + } + }
\ No newline at end of file |