I have Laravel website, then there have form for passing data to database. But while fill the form and trying to submit the data, I getting server error 500. So after I enable debug value as a ‘true’. Then I saw error like this,
“Illuminate
Database
QueryException
PHP 8.1.15
9.17.0
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘5’ for key ‘PRIMARY’ (SQL: insert into properties
(l_id
, p_id
, p_name
, size
, type
, status
, province
, district
, city
, dic
, price
, img
, updated_at
, created_at
) values (005, 5, Thalalla – Land, 182,”
app
/
Http
/
Controllers
/
PropertyController
.php
: 50
$newProperty->city = $request->input('city');
$newProperty->dic = $request->input('dic');
$newProperty->price = $request->input('price');
$img = $request->file('img_path');
$path = $img->store('images/resource/property/main/', ['disk' => 'my_files']);
$newProperty->img = "public/".$path;
foreach ($salse as $table_data){
if($name == $table_data->p_name && $district == $table_data->district){
dump($newProperty);
$action = "error";
echo('--------------');
dd($table_data);
}
}
if($action == "ok"){
$newProperty->save();
foreach ($request->file('more_img_path') as $imagefile) {
$image = new Image;
$path2 = $imagefile->store('images/resource/property/gallery/', ['disk' => 'my_files']);
$image->p_id = $property_id;
$image->img = "public/".$path2;
$image->save();
}
// **********************activity log************************
$newLog = new Log();
$uname;
$user;
foreach(session('login_user') as $id => $details){
$uname = $details['name'];
I’m mention below error screenshot. There showing error “newProperty(save);” code line.
Can someone help me to fix this error? enter image description here