mirror of
https://github.com/Deathgarden-Rebirth/Deathgarden_Rebirth-Rewrite.git
synced 2026-09-08 11:15:09 -05:00
Changed some descriptions of the admin tools for Miraak. Aded some more Permissions and added a moderator role.
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api\Admin\Tools;
|
|
|
|
use App\APIClients\HttpMethod;
|
|
use App\Enums\Auth\Permissions;
|
|
use Auth;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class BanPostRequest extends FormRequest
|
|
{
|
|
public string $reason;
|
|
|
|
public Carbon $startDate;
|
|
|
|
public Carbon $endDate;
|
|
|
|
public HttpMethod $editMethod;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Auth::user()?->can(Permissions::USER_BANS->value);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'method' => [Rule::enum(HttpMethod::class), 'required'],
|
|
'reason' => 'string|required',
|
|
'startDate' => 'date|required',
|
|
'endDate' => 'date|required',
|
|
];
|
|
}
|
|
|
|
public function passedValidation()
|
|
{
|
|
$fromTimezone = 'Europe/Berlin';
|
|
|
|
$this->reason = $this->input('reason');
|
|
$this->startDate = Carbon::parse($this->input('startDate'), $fromTimezone);
|
|
$this->endDate = Carbon::parse($this->input('endDate'), $fromTimezone);
|
|
$this->editMethod = HttpMethod::from($this->input('method'));
|
|
}
|
|
}
|