|string> */ public function rules(): array { return [ 'email' => 'required|string|email', 'password' => 'required|string', ]; } /** * Configure the validator instance. */ public function withValidator(Validator $validator): void { $validator->after(function (Validator $validator) { $email = $this->input('email'); $password = $this->input('password'); // Find user by email $user = User::where('email', $email)->first(); if (!$user) { $validator->errors()->add('email', 'User with this email does not exist.'); return; } // Check if user is admin if ($user->role !== 'admin') { $validator->errors()->add('email', 'Only administrators can perform system reboot.'); return; } // Verify password if (!Hash::check($password, $user->password)) { $validator->errors()->add('password', 'The provided password is incorrect.'); return; } }); } }