feat: add travel type request validation
This commit is contained in:
@@ -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'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user