75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class BulkAuditionEditRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
// TODO write authorize
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
if (! $this->has('editEvent')) {
|
|
$this->request->remove('event_id');
|
|
}
|
|
if (! $this->has('editDeadline')) {
|
|
$this->request->remove('entry_deadline');
|
|
}
|
|
if (! $this->has('editFee')) {
|
|
$this->request->remove('entry_fee');
|
|
}
|
|
if (! $this->has('editMinGrade')) {
|
|
$this->request->remove('minimum_grade');
|
|
}
|
|
if (! $this->has('editMaxGrade')) {
|
|
$this->request->remove('maximum_grade');
|
|
}
|
|
if (! $this->has('editScope')) {
|
|
$this->request->remove('for_seating');
|
|
$this->request->remove('for_advancement');
|
|
}
|
|
if ($this->has('editScope')) {
|
|
if ($this->has('for_seating')) {
|
|
$this->merge(['for_seating' => true]);
|
|
} else {
|
|
$this->merge(['for_seating' => false]);
|
|
}
|
|
|
|
if ($this->has('for_advancement')) {
|
|
$this->merge(['for_advancement' => true]);
|
|
} else {
|
|
$this->merge(['for_advancement' => false]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'auditions' => 'required|array|min:1',
|
|
'auditions.*' => 'required|exists:auditions,id',
|
|
'event_id' => 'sometimes|exists:events,id',
|
|
'entry_deadline' => 'sometimes|date',
|
|
'entry_fee' => 'sometimes|numeric',
|
|
'minimum_grade' => 'sometimes|integer|min:1',
|
|
'maximum_grade' => 'sometimes|integer|min:1',
|
|
'for_seating' => 'sometimes|boolean',
|
|
'for_advancement' => 'sometimes|boolean',
|
|
'editScope' => 'sometimes|boolean',
|
|
];
|
|
}
|
|
}
|