Files
postshop-backend/app/Modules/GlobalOrder/Controllers/Requests/GlobalOrderStoreRequest.php
2026-02-03 15:31:29 +05:00

44 lines
1.4 KiB
PHP

<?php
namespace App\Modules\GlobalOrder\Controllers\Requests;
use App\Models\Ecommerce\Product\Order\Payment\OrderPayment;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\File as FileRule;
class GlobalOrderStoreRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'customer_name' => ['required', 'string', 'max:255'],
'customer_phone' => ['required', 'integer', 'between:61000000,71999999'],
'customer_address' => ['nullable', 'string', 'max:255'],
'payment_type' => ['required', 'string', Rule::in(array_keys(OrderPayment::oldButGoodTypes()))],
'notes' => ['nullable', 'string', 'max:255'],
'order_website' => ['nullable', 'string', 'max:255'],
'images.*' => ['nullable', FileRule::image()->min('1kb')->max('10mb')],
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array<string, string>
*/
public function messages(): array
{
return [
'payment_type.in' => sprintf('Valid sources: %s', implode(', ', array_keys(
OrderPayment::oldButGoodTypes()
))),
];
}
}