1
0

update api ticket type

This commit is contained in:
Wian Drs
2026-06-25 17:11:48 +07:00
parent ad472a9880
commit af1c98b38b
29 changed files with 1097 additions and 34 deletions
@@ -0,0 +1,55 @@
<?php
namespace App\Http\Requests\Audit;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class AuditLogFilterRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'module' => [
'nullable',
'string'
],
'action' => [
'nullable',
'string'
],
'user_id' => [
'nullable',
'integer'
],
'tenant_id' => [
'nullable',
'integer'
],
'per_page' => [
'nullable',
'integer',
'min:1',
'max:100'
]
];
}
}
@@ -23,10 +23,81 @@ class StoreTicketTypeRequest extends FormRequest
public function rules(): array
{
return [
'code' => 'required|string|max:50|unique:ticket_types,code',
'name' => 'required|string|max:100',
'need_approval' => 'boolean',
'sla_minutes' => 'nullable|integer'
'code' => [
'required',
'string',
'max:50',
'unique:ticket_types,code'
],
'name' => [
'required',
'string',
'max:100'
],
'need_approval' => [
'nullable',
'boolean'
],
'sla_minutes' => [
'nullable',
'integer',
'min:1'
],
'require_photo' => [
'nullable',
'boolean'
],
'require_material' => [
'nullable',
'boolean'
],
'need_customer' => [
'nullable',
'boolean'
],
'need_incident_type' => [
'nullable',
'boolean'
]
];
}
protected function prepareForValidation(): void
{
$this->merge([
'need_approval' => filter_var(
$this->need_approval,
FILTER_VALIDATE_BOOLEAN
),
'require_photo' => filter_var(
$this->require_photo,
FILTER_VALIDATE_BOOLEAN
),
'require_material' => filter_var(
$this->require_material,
FILTER_VALIDATE_BOOLEAN
),
'need_customer' => filter_var(
$this->need_customer,
FILTER_VALIDATE_BOOLEAN
),
'need_incident_type' => filter_var(
$this->need_incident_type,
FILTER_VALIDATE_BOOLEAN
)
]);
}
}
@@ -4,6 +4,7 @@ namespace App\Http\Requests\TicketType;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateTicketTypeRequest extends FormRequest
{
@@ -23,10 +24,82 @@ class UpdateTicketTypeRequest extends FormRequest
public function rules(): array
{
return [
'code' => 'sometimes|string|max:50|unique:ticket_types,code,' . $this->route('ticket_type'),
'name' => 'sometimes|string|max:100',
'need_approval' => 'sometimes|boolean',
'sla_minutes' => 'nullable|integer'
'code' => [
'required',
'string',
'max:50',
Rule::unique('ticket_types', 'code')
->ignore($this->ticket_type->id)
],
'name' => [
'required',
'string',
'max:100'
],
'need_approval' => [
'nullable',
'boolean'
],
'sla_minutes' => [
'nullable',
'integer',
'min:1'
],
'require_photo' => [
'nullable',
'boolean'
],
'require_material' => [
'nullable',
'boolean'
],
'need_customer' => [
'nullable',
'boolean'
],
'need_incident_type' => [
'nullable',
'boolean'
]
];
}
protected function prepareForValidation(): void
{
$this->merge([
'need_approval' => filter_var(
$this->need_approval,
FILTER_VALIDATE_BOOLEAN
),
'require_photo' => filter_var(
$this->require_photo,
FILTER_VALIDATE_BOOLEAN
),
'require_material' => filter_var(
$this->require_material,
FILTER_VALIDATE_BOOLEAN
),
'need_customer' => filter_var(
$this->need_customer,
FILTER_VALIDATE_BOOLEAN
),
'need_incident_type' => filter_var(
$this->need_incident_type,
FILTER_VALIDATE_BOOLEAN
)
]);
}
}