Working on Manual Payout Winner Selection
This commit is contained in:
parent
9c1b334fe8
commit
2ad2f32d07
6 changed files with 85 additions and 13 deletions
|
|
@ -3,8 +3,36 @@
|
|||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Season;
|
||||
use App\User;
|
||||
|
||||
class ManualPayout extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = [
|
||||
'season_id','quota_name','user_id'
|
||||
];
|
||||
|
||||
public static function getWinner($quotaName) {
|
||||
$season = Season::getCurrent();
|
||||
|
||||
$entry = ManualPayout::where('season_id','=', $season->id)->where('quota_name','=',$quotaName)->first();
|
||||
if (!$entry) return null;
|
||||
$user = User::where('id','=',$entry->user_id);
|
||||
return $user->first();
|
||||
}
|
||||
|
||||
public static function setWinner( $userId, $quotaName) {
|
||||
|
||||
$season = Season::getCurrent();
|
||||
|
||||
$entry = ManualPayout::where('season_id','=',$season->id)->where('quota_name','=',$quotaName)->first();
|
||||
if (!$entry) {
|
||||
$entry = new ManualPayout;
|
||||
$entry->user_id = $userId;
|
||||
$entry->season_id = $season->id;
|
||||
$entry->quota_name = $quotaName;
|
||||
}
|
||||
$entry->user_id = $userId;
|
||||
$entry->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue