2025-12-30 11:18:17 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
2026-01-13 19:45:44 +09:00
|
|
|
use App\Http\Requests\Traits\HasPagination;
|
2025-12-30 11:18:17 +09:00
|
|
|
use App\Models\Tenants\Position;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
|
|
class PositionRequest extends FormRequest
|
|
|
|
|
{
|
2026-01-13 19:45:44 +09:00
|
|
|
use HasPagination;
|
|
|
|
|
|
2025-12-30 11:18:17 +09:00
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
$method = $this->method();
|
|
|
|
|
|
|
|
|
|
if ($method === 'GET') {
|
|
|
|
|
return [
|
|
|
|
|
'type' => ['nullable', Rule::in([Position::TYPE_RANK, Position::TYPE_TITLE])],
|
|
|
|
|
'is_active' => 'nullable|boolean',
|
|
|
|
|
'q' => 'nullable|string|max:100',
|
2026-01-13 19:45:44 +09:00
|
|
|
'per_page' => 'nullable|integer|min:1',
|
2025-12-30 11:18:17 +09:00
|
|
|
'page' => 'nullable|integer|min:1',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($method === 'POST') {
|
|
|
|
|
return [
|
|
|
|
|
'type' => ['required', Rule::in([Position::TYPE_RANK, Position::TYPE_TITLE])],
|
|
|
|
|
'name' => 'required|string|max:50',
|
|
|
|
|
'sort_order' => 'nullable|integer|min:0',
|
|
|
|
|
'is_active' => 'nullable|boolean',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (in_array($method, ['PUT', 'PATCH'])) {
|
|
|
|
|
return [
|
|
|
|
|
'name' => 'nullable|string|max:50',
|
|
|
|
|
'sort_order' => 'nullable|integer|min:0',
|
|
|
|
|
'is_active' => 'nullable|boolean',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function messages(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'type.required' => __('validation.required', ['attribute' => '유형']),
|
|
|
|
|
'type.in' => __('validation.in', ['attribute' => '유형']),
|
|
|
|
|
'name.required' => __('validation.required', ['attribute' => '명칭']),
|
|
|
|
|
'name.max' => __('validation.max.string', ['attribute' => '명칭', 'max' => 50]),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|