feat: add form request validation classes
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class TourStoreRequest 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 [
|
||||
'travel_type_id' =>
|
||||
[
|
||||
'required',
|
||||
'exists:travel_types,id'
|
||||
],
|
||||
'title' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:200'
|
||||
],
|
||||
'slug' =>
|
||||
['required', 'string',
|
||||
'max:200',
|
||||
'regex:/^[a-z0-9-]+$/',
|
||||
'unique:tours,slug,' . $this->tour
|
||||
],
|
||||
|
||||
'description' =>
|
||||
[
|
||||
'required',
|
||||
'string'
|
||||
],
|
||||
'duration' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:50'
|
||||
],
|
||||
'start_date' =>
|
||||
[
|
||||
'required',
|
||||
'date'
|
||||
],
|
||||
'end_date' =>
|
||||
[
|
||||
'required',
|
||||
'date',
|
||||
'after_or_equal:start_date'
|
||||
],
|
||||
'price' =>
|
||||
[
|
||||
'required',
|
||||
'numeric',
|
||||
'min:0'
|
||||
],
|
||||
'capacity' =>
|
||||
[
|
||||
'required',
|
||||
'integer',
|
||||
'min:0'],
|
||||
'status' =>
|
||||
[
|
||||
'nullable',
|
||||
'in:0,1'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user