27 lines
799 B
PHP
27 lines
799 B
PHP
<?php
|
|
|
|
namespace App\leagues;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Log;
|
|
|
|
class League extends Model
|
|
{
|
|
protected $table ='leagues';
|
|
protected $fillable = [
|
|
'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;
|
|
}
|
|
}
|