Answers for "laravel check "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry"

PHP
0

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);
    }
Posted by: Guest on September-20-2021

Code answers related to "laravel check "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry"

Browse Popular Code Answers by Language