feat: add travel type request validation

This commit is contained in:
2026-08-17 19:42:44 +03:30
parent cb15c63a05
commit 12d56c2c9f
2 changed files with 91 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class TravelTypeStoreRequest 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 [
'title' =>
[
'required',
'string',
'max:100'
],
'slug' =>
[
'required',
'string',
'max:150',
'unique:travel_types,slug'
],
'status' =>
[
'sometimes',
'in:0,1'
],
];
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class TravelTypeUpdateRequest 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 [
'title' =>
['required',
'string',
'max:100'
],
'slug' =>
[
'required',
'string',
'max:150',
Rule::unique('travel_types', 'slug')->ignore($this->travelType)],
'status' =>
[
'sometimes',
'in:0,1'
],
];
}
}