-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a form to add new punishments reasons for a specified game server.
- Loading branch information
Showing
8 changed files
with
219 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/Http/Requests/Dashboard/GameServer/PunishmentReason/StoreRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Dashboard\GameServer\PunishmentReason; | ||
|
||
use Carbon\CarbonInterval; | ||
use App\Models\GameServer\GameServer; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Validation\Rule; | ||
|
||
/** | ||
* @property GameServer $game_server | ||
*/ | ||
class StoreRequest extends FormRequest | ||
{ | ||
/** | ||
* Determine if the user is authorized to make this request. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'name' => ['required', 'string', 'max:255', | ||
Rule::unique('punishment_reasons')->where('game_server_id', $this->game_server->id) | ||
], | ||
'months' => ['required', 'numeric', 'min:0'], | ||
'days' => ['required', 'numeric', 'min:0'], | ||
'hours' => ['required', 'numeric', 'min:0'], | ||
'minutes' => ['required', 'numeric', 'min:0'], | ||
'time' => ['required', 'numeric', 'min:0'], | ||
'game_server_id' => ['required', 'integer'], | ||
]; | ||
} | ||
|
||
/** | ||
* Prepare the data for validation. | ||
* | ||
* @return void | ||
*/ | ||
protected function prepareForValidation(): void | ||
{ | ||
$this->merge([ | ||
'game_server_id' => $this->game_server->id, | ||
'time' => CarbonInterval::months($this->input('months')) | ||
->days($this->input('days')) | ||
->hours($this->input('hours')) | ||
->minutes($this->input('minutes')) | ||
->totalMinutes | ||
]); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...GameServer/Reason/UpdateReasonRequest.php → ...Server/PunishmentReason/UpdateRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 0 additions & 63 deletions
63
app/Http/Requests/Dashboard/GameServer/Reason/StoreReasonRequest.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
resources/js/Pages/Dashboard/GameServers/PunishmentReasons/Create.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<script setup> | ||
import DashboardLayout from '@/Layouts/Dashboard.vue'; | ||
import { useForm } from '@inertiajs/vue3'; | ||
import InputError from "@/Components/InputError.vue"; | ||
import BackButton from "@/Components/Buttons/BackButton.vue"; | ||
import CreateButton from "@/Components/Buttons/CreateButton.vue"; | ||
defineOptions({ | ||
layout: DashboardLayout | ||
}); | ||
const props = defineProps({ | ||
title: String, | ||
gameServer: Object, | ||
}); | ||
const form = useForm({ | ||
name: '', | ||
months: 0, | ||
days: 0, | ||
hours: 0, | ||
minutes: 0, | ||
}); | ||
const store = () => { | ||
form.post(route('dashboard.game-servers.punishment-reasons.store', props.gameServer)); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="ml-4 space-y-4"> | ||
<div class="flex items-center space-x-4 mx-4"> | ||
<div class="grow"> | ||
<h1 class="text-xl">{{ title }}</h1> | ||
</div> | ||
<div class="flex-none"> | ||
<BackButton title="Назад" :href="route('dashboard.game-servers.show', props.gameServer)" /> | ||
</div> | ||
</div> | ||
<form @submit.prevent="store"> | ||
<div class="bg-base-200 rounded-box p-4"> | ||
<div class="grid grid-cols-6 gap-x-6"> | ||
<div class="col-span-3"> | ||
<label for="name" class="label"> | ||
<span class="text-base label-text">{{ ('Название причины') }}</span> | ||
</label> | ||
<input | ||
id="name" | ||
name="name" | ||
type="text" | ||
class="input input-bordered w-full focus:ring-1 focus:ring-offset-2 focus:ring-offset-base-200 focus:ring-orange-500" | ||
v-model="form.name" | ||
required | ||
autofocus /> | ||
<InputError :message="form.errors.name" /> | ||
</div> | ||
</div> | ||
<div class="mt-2"> | ||
<label class="label"> | ||
<span class="text-base label-text">{{ ('Длительность наказания') }}</span> | ||
</label> | ||
<div class="grid grid-cols-6 gap-x-6"> | ||
<div> | ||
<label for="months" class="label"> | ||
<span class="label-text">{{ ('Месяцы') }}</span> | ||
</label> | ||
<input | ||
id="months" | ||
name="months" | ||
type="number" | ||
class="input input-bordered w-full focus:ring-1 focus:ring-offset-2 focus:ring-offset-base-200 focus:ring-orange-500" | ||
v-model.number="form.months" | ||
min="0" | ||
value="0" /> | ||
<InputError :message="form.errors.months" /> | ||
</div> | ||
<div> | ||
<label for="days" class="label"> | ||
<span class="label-text">{{ ('Дни') }}</span> | ||
</label> | ||
<input | ||
id="days" | ||
name="days" | ||
type="number" | ||
class="input input-bordered w-full focus:ring-1 focus:ring-offset-2 focus:ring-offset-base-200 focus:ring-orange-500" | ||
v-model.number="form.days" | ||
min="0" | ||
value="0" /> | ||
<InputError :message="form.errors.days" /> | ||
</div> | ||
<div> | ||
<label for="hours" class="label"> | ||
<span class="label-text">{{ ('Часы') }}</span> | ||
</label> | ||
<input | ||
id="hours" | ||
name="hours" | ||
type="number" | ||
class="input input-bordered w-full focus:ring-1 focus:ring-offset-2 focus:ring-offset-base-200 focus:ring-orange-500" | ||
v-model.number="form.hours" | ||
min="0" | ||
value="0" /> | ||
<InputError :message="form.errors.hours" /> | ||
</div> | ||
<div> | ||
<label for="minutes" class="label"> | ||
<span class="label-text">{{ ('Минуты') }}</span> | ||
</label> | ||
<input | ||
id="minutes" | ||
name="minutes" | ||
type="number" | ||
class="input input-bordered w-full focus:ring-1 focus:ring-offset-2 focus:ring-offset-base-200 focus:ring-orange-500" | ||
v-model.number="form.minutes" | ||
min="0" | ||
value="0" /> | ||
<InputError :message="form.errors.minutes" /> | ||
</div> | ||
</div> | ||
<div class="flex mt-2"> | ||
<span class="label-text"> | ||
{{ ('Оставьте все значения равными нулю для указания бессрочного действия наказания.') }} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="flex justify-end m-4"> | ||
<CreateButton title="Добавить" :disabled="!form.isDirty" /> | ||
</div> | ||
</form> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters