mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-09-08 19:25:10 -05:00
Forgot to change the false of the Authorize() method. Fixed comparison of Match creator and user that send teh request. To compare objects don't use ===, use == instead.
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\Matchmaking;
|
|
|
|
use App\Enums\Game\Faction;
|
|
use Auth;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class EndOfMatchRequest extends FormRequest
|
|
{
|
|
public array $players;
|
|
|
|
public Faction $dominantFaction;
|
|
|
|
public string $matchId;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Auth::check();
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'data.players' => 'present|array',
|
|
'data.dominantFaction' => ['required', Rule::enum(Faction::class)],
|
|
'data.matchId' => 'required|string',
|
|
];
|
|
}
|
|
|
|
protected function passedValidation()
|
|
{
|
|
$this->players = $this->input('data.players');
|
|
$this->dominantFaction = Faction::tryFrom($this->input('data.dominantFaction'));
|
|
$this->matchId = $this->input('data.matchId');
|
|
}
|
|
}
|