HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //var/www/html/dashboard.orbiwheels.com/app/Http/Requests/Admin/UserRequest.php
<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class UserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
         $rules = [
            'first_name' => 'required|string',
            'last_name' => 'required|string',
            'email' => 'required|string|email',
            'phone' => 'required|string',
            'role' => 'required',
        ];

        if ($this->isMethod('post')) {
            $rules['password'] = 'required|string|confirmed|min:6';
            $rules['email'] .= '|unique:users,email';
            $rules['phone'] .= '|unique:users,phone';
        } elseif ($this->isMethod('put')) {
            $userId = $this->route('id');
            $rules['password'] = 'nullable|string|confirmed|min:6';
            $rules['email'] .= '|unique:users,email,' . $userId;
            $rules['phone'] .= '|unique:users,phone,' . $userId;
        }

        return $rules;
    }
}