I am using a custom made API Request to my database to generate a new entry.
My table structure looks like this:
Table Structure
Schema::create('incidents', function (Blueprint $table) {
$table->increments('id');
$table->string('incident_id')->unique();
$table->integer('incident_type')->unsigned();
$table->string('location');
$table->string('street');
$table->string('city');
$table->double('latitude', 10, 6);
$table->double('longitude', 10, 6);
$table->date('date');
$table->time('time');
$table->smallInteger('incident_archived')->default(0);
$table->timestamps();
});
I set the Incident_Type to Unique as this is a requirement for my system. When I post a new entry to the system:
SERVER_IP/v1/incidents?incident_id=1&city=Muenchen&street=Fichtenstr.20&latitude=100&longitude=300
The first time works fine.
The second time:
SERVER_IP/v1/incidents?incident_id=2&city=Muenchen&street=Fichtenstr.20&latitude=100&longitude=300
when I use different incident_id I get the error:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'incidents_incident_id_unique' (SQL: insert into `incidents` (`street`, `city`, `latitude`, `longitude`, `updated_at`, `created_at`) values (Fichtenstr.20, Muenchen, 100, 300, 2015-10-17 12:28:11, 2015-10-17 12:28:11))
Why is sending the request using the exact same entry even if I changed the data? And how can I fix this?