tippspiel/pfosten/app/leagues/League.php

32 lines
986 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;
}
public static function getMemberCount($league_id) {
$members = DB::table('leagues_matches')->where('league_id','=',$league_id)->get();
return sizeof($members);
}
}