Files
shahrzadzandi09/app/Http/Requests/TourStoreRequest.php
T
2026-08-17 19:53:12 +03:30

97 lines
2.3 KiB
PHP

<?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'],
'images' =>
[
'required',
'array'
],
'images.*' =>
[
'image',
'mimes:jpeg,png,jpg,webp',
'max:2048'
],
'status' =>
[
'nullable',
'in:0,1'
],
];
}
}