League Creation

This commit is contained in:
Torsten 2017-09-11 10:38:57 +02:00
parent 96101cb05d
commit 7c9d5eef1e
11 changed files with 160 additions and 46 deletions

View file

@ -3,12 +3,25 @@
namespace App\leagues;
use Illuminate\Database\Eloquent\Model;
use Log;
class League extends Model
{
protected $table ='leagues';
protected $fillable = [
'id','season_id','rank','subrank','start_round_id','name'
'id','season_id','is_qualification','rank','subrank','start_round_id','round_count','name'
];
//
public static function neededLeagues($member_count, $round_count) {
$max_members_per_league=22;
if ( $round_count < $max_members_per_league-1 ) { $max_members_per_league = $round_count+1; }
if ($member_count <= $max_members_per_league) return $member_count;
$neededLeagues = intdiv($member_count, $max_members_per_league);
if ( $member_count - $max_members_per_league * $neededLeagues ) {
$neededLeagues+=1;
}
return $neededLeagues;
}
}