X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FResult.php;h=99f3791eacfc951acabb8d69d22053f592adbc80;hb=4aeaa2ab482a0915da0016fc8175e7cbaa0ab261;hp=cdb86c77798fb2bccb204c740ee0ced94473bf71;hpb=d32516335ea2534e15256c948e9c38d3de40794b;p=alttp.git diff --git a/app/Models/Result.php b/app/Models/Result.php index cdb86c7..99f3791 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -11,6 +11,13 @@ class Result extends Model use HasFactory; + public function formatTime() { + $hours = floor($this->time / 60 / 60); + $minutes = floor(($this->time / 60) % 60); + $seconds = floor($this->time % 60); + return sprintf('%d:%02d:%02d', $hours, $minutes, $seconds); + } + public function updateResult($time, $forfeit) { $this->time = $time; $this->forfeit = $forfeit; @@ -43,6 +50,11 @@ class Result extends Model } + protected $casts = [ + 'forfeit' => 'boolean', + 'time' => 'double', + ]; + protected $appends = [ 'has_finished', ];