File "StoreVendorRequest.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Requests/Admin/StoreVendorRequest.php
File size: 1.49 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Http\Requests\Admin;

use Gate;
use Illuminate\Foundation\Http\FormRequest;

class StoreVendorRequest extends FormRequest
{
    public function authorize()
    {
        return Gate::allows('vendor_create');
    }

    public function rules()
    {
        return [
            'name' => [
                'required',
                'string',
                'max:50',
            ],
            'email' => [
                'required',
                'string',
                'email',
            ],
            'secondary_email' => [
                'nullable',
                'string',
                'email',
            ],
            'phone' => [
                'required',
                'numeric',
                'max_digits:20',
            ],
            'address' => [
                'nullable',
            ],
            'account_number' => [
                'nullable',
            ],
            'payment_terms' => [
                'nullable',
            ],
            'credit_card_ending' => [
                'nullable',
                'regex:/^\d{4}$/',
            ],
        ];
    }

    public function messages()
    {
        return [
            'credit_card_ending.regex' => 'Card ending must be valid 4 digits.',
            'phone.required' => 'The phone number field is required.',
            'phone.numeric' => 'The phone number must contain only numbers.',
            'phone.max_digits' => 'The phone number can not be longer than 20 digits.',
        ];
    }
}