'SQLSTATE[22007] error when inserting data into 2 tables

I'm trying to insert data into 2 separate tables here; first, it sends it to "EmpDetails" then "Employees" but gives an error which I've included a screenshot of.

I've spent hours searching for a solution and haven't found a solution or I'm looking at the wrong sources.

Error when inserting data into Employee table

I've disabled the default timestamp in models and it's still the same. Could someone please help me here, I'm short on time and need some quick help please and thank you.

$empDetail = new EmpDetail();


    
    $empDetail -> cnic = $registerRequest->EmployeeCnic;
    $empDetail -> city = $registerRequest->EmployeeNumber;
    $empDetail -> address = $registerRequest->EmployeeCity;
    $empDetail -> phone = $registerRequest->EmployeeAddress;
    $empDetail -> designation = $registerRequest->EmployeeDesignation;

    $emp = $empDetail -> save();

    $emp = new Employee();
    



    $emp -> name = $registerRequest->EmployeeName;
    $emp -> details = EmpDetail::where('cnic','=', $registerRequest->EmployeeCnic)->first();

    $res = $emp -> save();


Solution 1:[1]

I'm not sure if you made this mistake when you were creating your question but I think that you've misplaced the request names with the wrong database fields (city, address, and phone):

Wrong:

$empDetail->city = $registerRequest->EmployeeNumber;
$empDetail->address = $registerRequest->EmployeeCity;
$empDetail->phone = $registerRequest->EmployeeAddress;

Correct:

$empDetail->city = $registerRequest->EmployeeCity;
$empDetail->address = $registerRequest->EmployeeAddress;
$empDetail->phone = $registerRequest->EmployeeNumber;

*If this isn't the case, then please provide more information from your code for example models, migrations, and controllers that you've used so I can try to recreate it on my machine and provide a useful answer for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Njazi Shehu