HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/blijegasten/blijegasten.be/app/Komma/Shop/Checkout/Request/CheckoutDataRequest.php
<?php

namespace App\Komma\Shop\Checkout\Request;

use App\Komma\Addresses\Models\Address;
use App\Komma\Globalization\Rules\ValidCountryIso3;
use Illuminate\Foundation\Http\FormRequest;

/**
 * Class CheckoutRequest
 *
 * Validates a checkout request.
 *
 * @package App\Komma\Shop\Checkout
 */
class CheckoutDataRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $validationRules = [
            'clientType' => 'required',
            'invoice_company' => 'required_if:clientType,business',
            'invoice_vat_number' => 'required_if:clientType,business',
            'first_name' => 'required',
            'last_name' => 'required',
            'email' => 'required',
            'phone' => 'required|string|min:7|max:20',

            'invoice_street' => 'required|' . Address::getValidationRules('street'),
            'invoice_house_number' => 'required|' . Address::getValidationRules('house_number'),
            'invoice_postal_code' => 'required|' . Address::getValidationRules('postal_code'),
            'invoice_city' => 'required|' . Address::getValidationRules('city'),
            'invoice_country' => 'required',

            'shipping_street' => 'required_if:other_shipping_address,on|' . Address::getValidationRules('street'),
            'shipping_house_number' => 'required_if:other_shipping_address,on|' . Address::getValidationRules('house_number'),
            'shipping_postal_code' => 'required_if:other_shipping_address,on|' . Address::getValidationRules('postal_code'),
            'shipping_city' => 'required_if:other_shipping_address,on|' . Address::getValidationRules('city'),
            'shipping_country' => 'required_if:other_shipping_address,on',
        ];

        return $validationRules;

    }

    /**
     * Get custom messages for validator error
     *
     * @return array
     */
    public function messages()
    {
        $messages = [
//            'terms_and_conditions.accepted' => __('shop/checkout.validation.terms_and_conditions.accepted'),
            'invoice_company.required_if' => __('validation.requiredIfBusiness', ['attribute' => __('validation.attributes.invoice_company')]),
            'invoice_vat_number.required_if' => __('validation.requiredIfBusiness', ['attribute' => __('validation.attributes.invoice_vat_number')]),
        ];

        foreach (['street', 'house_number', 'postal_code', 'city', 'phone'] as $messageKeyPart) {
            $messages['shipping_' . $messageKeyPart .'.required_if'] = __('validation.requiredIfOtherShippingAddress', ['attribute' => __('validation.attributes.shipping_' . $messageKeyPart)]);
        }

        return $messages;
    }
}