laravel check 22sqlstate 5b23000 5d 3a integrity constraint violation 3a 1062 duplicate entry

Solutions on MaxInterview for laravel check 22sqlstate 5b23000 5d 3a integrity constraint violation 3a 1062 duplicate entry by the best coders in the world

showing results for - "laravel check 22sqlstate 5b23000 5d 3a integrity constraint violation 3a 1062 duplicate entry"
Francesca
03 Nov 2016
1according to this sample:
2
3
4    public function store(ServiceStoreRequest $request, int $id)
5    {
6        $service = new Serviceable();
7        $service->package_id = $id;
8        $service->fill($request->all());
9        try {
10            $service->save();
11        } catch (\Exception $exception) {
12            return response(array(
13                "code"=> 409,
14                "error"=>"duplicate " . $exception->getMessage()));
15        }
16        return response($service);
17    }