diff --git a/app/Enums/PaymentStatus.php b/app/Enums/PaymentStatus.php new file mode 100644 index 0000000..721d226 --- /dev/null +++ b/app/Enums/PaymentStatus.php @@ -0,0 +1,33 @@ + 'در انتظار پرداخت', + self::Success => 'پرداخت موفق', + self::Failed => 'پرداخت ناموفق', + self::Canceled => 'لغو شده / بازگشت وجه', + }; + } + + // کلاس رنگ برای بج (بدج) در جدول + public function color(): string + { + return match ($this) { + self::Pending => 'warning', + self::Success => 'success', + self::Failed => 'danger', + self::Canceled => 'secondary', + }; + } +} diff --git a/app/Http/Requests/AirportStoreRequest.php b/app/Http/Requests/AirportStoreRequest.php new file mode 100644 index 0000000..70fe01e --- /dev/null +++ b/app/Http/Requests/AirportStoreRequest.php @@ -0,0 +1,66 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => + [ + 'required', + 'string', + 'max:150' + ], + 'city' => + [ + 'required', + 'string', + 'max:100' + ], + 'country' => + [ + 'required', + 'string', + 'max:100' + ], + 'code' => + [ + 'required', + 'string', + 'max:10' + ], + ]; + } + +// public function messages(): array +// { +// return [ +// 'name.required' => 'نام فرودگاه الزامی است.', +// 'name.max' => 'نام فرودگاه حداکثر ۱۵۰ کاراکتر باشد.', +// 'city.required' => 'نام شهر الزامی است.', +// 'city.max' => 'نام شهر حداکثر ۱۰۰ کاراکتر باشد.', +// 'country.required' => 'نام کشور الزامی است.', +// 'country.max' => 'نام کشور حداکثر ۱۰۰ کاراکتر باشد.', +// 'code.required' => 'کد فرودگاه (IATA) الزامی است.', +// 'code.max' => 'کد فرودگاه حداکثر ۱۰ کاراکتر باشد.', +// ]; +// } +} diff --git a/app/Http/Requests/CommentUpdateRequest.php b/app/Http/Requests/CommentUpdateRequest.php new file mode 100644 index 0000000..5d3a211 --- /dev/null +++ b/app/Http/Requests/CommentUpdateRequest.php @@ -0,0 +1,40 @@ +|string> + */ + public function rules(): array + { + return [ + 'body' => + [ + 'required', + 'string' + ], + 'status' => + [ + 'required', + 'integer', + Rule::in([0, 1, 2]) + ] + ]; + } +} diff --git a/app/Http/Requests/FavoriteUpdateRequest.php b/app/Http/Requests/FavoriteUpdateRequest.php new file mode 100644 index 0000000..74ba9c6 --- /dev/null +++ b/app/Http/Requests/FavoriteUpdateRequest.php @@ -0,0 +1,43 @@ +|string> + */ + public function rules(): array + { + return [ + 'user_id' => + [ + 'required', 'integer', 'exists:users,id' + ], + 'favoritable_id' => + [ + 'required', + 'integer' + ], + 'favoritable_type' => + [ + 'required', + 'string', + 'max:100' + ], + ]; + } +} diff --git a/app/Http/Requests/SettingUpdateRequest.php b/app/Http/Requests/SettingUpdateRequest.php new file mode 100644 index 0000000..00b2916 --- /dev/null +++ b/app/Http/Requests/SettingUpdateRequest.php @@ -0,0 +1,49 @@ +all(); + + // فقط codeهایی که در جدول وجود دارند را نگاه می‌داریم + $filtered = Arr::only($this->all(), $allowedCodes); + + $this->merge($filtered); + } + + /** + * قوانین اعتبارسنجی. + */ + public function rules(): array + { + $codes = Setting::pluck('code')->all(); + + return collect($codes) + ->mapWithKeys(fn($code) => [ + $code => [ + 'nullable', + 'string', + 'max:65535' + ], + ]) + ->all(); + } +} diff --git a/app/Http/Requests/TourStoreRequest.php b/app/Http/Requests/TourStoreRequest.php new file mode 100644 index 0000000..8673ff1 --- /dev/null +++ b/app/Http/Requests/TourStoreRequest.php @@ -0,0 +1,84 @@ +|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' + ], + ]; + } +} diff --git a/app/Http/Requests/UserStoreRequest.php b/app/Http/Requests/UserStoreRequest.php new file mode 100644 index 0000000..f09db4a --- /dev/null +++ b/app/Http/Requests/UserStoreRequest.php @@ -0,0 +1,61 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => + [ + 'required', + 'string', + 'max:255' + ], + + 'email' => + [ + 'required', + 'string', + 'email', + 'max:255', + 'unique:users,email' + ], + 'password' => + [ + 'required', + 'confirmed', + Password::defaults() + ], + ]; + } +// public function messages(): array +// { +// return [ +// 'name.required' => 'نام و نام خانوادگی الزامی است.', +// 'email.required' => 'ایمیل الزامی است.', +// 'email.email' => 'فرمت ایمیل معتبر نیست.', +// 'email.unique' => 'این ایمیل قبلاً ثبت شده است.', +// 'password.required' => 'رمز عبور الزامی است.', +// 'password.confirmed' => 'تکرار رمز عبور مطابقت ندارد.', +// ]; +// } +}