I am implementing a simple post query and I have implemented a similar one before and everything was fine, but here I get this error. And it occurs somewhere deep in the console that even I do not see it at once
controller
`class OperatorController extends Controller
{
public function index()
{
$ldap_users = LdapUser::all();
return view('pages.home')->with('ldap_users', $ldap_users);
}
public function storeUser(LdapUserStoreRequest $request)
{
try {
$validatedData = $request->validated();
Log::error("тут "`your text` .$validatedData );
$validatedData['full_name'] = $this->generateLogin($validatedData['full_name']);
LdapUser::create($validatedData);
} catch (Exception $e) {
Log::error("Ошибка при создании пользователя: " . $e->getMessage());
return response("Ошибка при создании пользователя", 202);
}
return response('success', 201);
}}`
web.php
Route::middleware("auth:web")->group(function () {
Route::get('/', [OperatorController::class, 'index'])->name('home');
Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
Route::post('/createUser', [OperatorController::class, 'storeUser'])->name('createUser');
});
js script
<script>
function createUser2() {
var userPanel = document.getElementById("userPanel");
var formData = new FormData(userPanel);
var xhr = new XMLHttpRequest();
var csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
xhr.open('POST', '{{ route("createUser") }}');
xhr.setRequestHeader('X-CSRF-TOKEN', csrfToken);
xhr.onload = function () {
if (xhr.status === 201) {
alert('Пользователь успешно создан!');
document.getElementById("createUserError").textContent = "";
} else if (xhr.status === 202) {
document.getElementById("createUserError").textContent =
"Ошибка: " +xhr.responseText;
} else if (xhr.status === 200) {
document.getElementById("createUserError").textContent = "Ошибка введённых данных";
}
};
xhr.send(formData);
console.error(xhr.statusText);
}
</script>
blade.php
<div id="createUserModal" class="modal">
<div class="create-modal-content">
<h2>Создание нового пользователя
<button class="btn btn-danger close-button " onclick="closeCreateUserPanel()">Закрыть</button>
</h2>
<form id="userPanel">
<div id="createUserError"></div>
<table>
<tr>
<th>Full Name</th>
<th>Mobile phone</th>
<th>Internal phone</th>
<th>Department</th>
</tr>
<tr>
<td><input type='text' name='full_name' id="createUserFullName" placeholder='Full Name'></td>
<td><input type='text' name='m_phone' id="createUserMPhone" placeholder='Mobile phone'></td>
<td><input type='text' name='i_phone' id="createUserIPhone" placeholder='Internal phone'></td>
<td><input type='text' name='department' id="createUserDepartment" placeholder='Department'></td>
<td>
<button class='btn btn-primary create-btn' type='button' onclick="createUser2()">Создать</button>
</td>
</tr>
</table>
</form>
</div>
</div>
always got code 200 and "No resource with given identifier found"
I tried rerouting and changing the controller and trying to send the data differently, but all I see is this.
im stupid and just named parameters differently. In request rules i named mobile_phone but in html m_phone and didnt see mistakes from ide