laravel check "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
according to this sample:
public function store(ServiceStoreRequest $request, int $id)
{
$service = new Serviceable();
$service->package_id = $id;
$service->fill($request->all());
try {
$service->save();
} catch (\Exception $exception) {
return response(array(
"code"=> 409,
"error"=>"duplicate " . $exception->getMessage()));
}
return response($service);
}