diff --git a/app/Http/Controllers/ClientApiController.php b/app/Http/Controllers/ClientApiController.php index aa5c2fa6bfd4..a3fea1435fb4 100644 --- a/app/Http/Controllers/ClientApiController.php +++ b/app/Http/Controllers/ClientApiController.php @@ -1,5 +1,6 @@ action == ACTION_ARCHIVE) { - $client = Client::scope($publicId)->withTrashed()->first(); - if(!$client) - return $this->errorResponse(['message'=>'Client not found.']); + try { + $client = Client::scope($publicId)->withTrashed()->firstOrFail(); + } catch (ModelNotFoundException $e) { + return $this->errorResponse(['message'=>'Record not found'], 400); + } $this->clientRepo->archive($client);