File "UpdateProfileRequest.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Requests/Admin/UpdateProfileRequest.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;
use Illuminate\Http\Response;

class UpdateProfileRequest 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()
    {
        return [
            'name'  => ['required', 'string', 'max:50'],
//            'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email,' . auth()->id()],
            'phone_number' => ['required_if:sms_notification,1', 'nullable', 'max:20'],
            'company' => ['nullable', 'max:20'],
            'fax_number' => ['nullable', 'max:20'],
            'password' => ['nullable', 'confirmed', 'regex:/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/i'],
            'profile_image' => [
                'nullable',
                'mimes:jpg,gif,png',
                'max:4096'
            ],
        ];
    }

    public function messages()
    {
        return [
            'password.regex' => 'Password should contain at least 8 characters, one letter, one number & one special character',
            'phone_number.required_if' => 'You must provide phone number in order to receive SMS notifications.',
            'phone_number.integer' => 'Phone number can only contain numbers.',
        ];
    }
}