|
|
@@ -5,6 +5,8 @@ namespace App\Http\Controllers;
|
|
|
use App\Http\Resources\DashboardClienteResource;
|
|
|
use App\Http\Resources\DashboardPrestadorResource;
|
|
|
use App\Services\DashboardService;
|
|
|
+use Illuminate\Auth\Access\AuthorizationException;
|
|
|
+use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
@@ -20,9 +22,12 @@ class DashboardController extends Controller
|
|
|
return $this->successResponse(
|
|
|
payload: new DashboardClienteResource($dados),
|
|
|
);
|
|
|
+ } catch (AuthorizationException $e) {
|
|
|
+ return $this->errorResponse(message: $e->getMessage(), code: 403);
|
|
|
+ } catch (ModelNotFoundException) {
|
|
|
+ return $this->errorResponse(message: 'Cliente não encontrado.', code: 404);
|
|
|
} catch (\Exception $e) {
|
|
|
Log::error('Erro ao obter dados do dashboard do cliente: '.$e->getMessage());
|
|
|
-
|
|
|
return $this->errorResponse(message: __('messages.error_fetching_data'), code: 500);
|
|
|
}
|
|
|
}
|
|
|
@@ -35,7 +40,6 @@ class DashboardController extends Controller
|
|
|
return $this->successResponse(payload: $dados);
|
|
|
} catch (\Exception $e) {
|
|
|
Log::error('Erro ao obter detalhes do schedule do cliente: '.$e->getMessage());
|
|
|
-
|
|
|
return $this->errorResponse(message: __('messages.error_fetching_data'), code: 500);
|
|
|
}
|
|
|
}
|
|
|
@@ -48,9 +52,12 @@ class DashboardController extends Controller
|
|
|
return $this->successResponse(
|
|
|
payload: new DashboardPrestadorResource($dados),
|
|
|
);
|
|
|
+ } catch (AuthorizationException $e) {
|
|
|
+ return $this->errorResponse(message: $e->getMessage(), code: 403);
|
|
|
+ } catch (ModelNotFoundException) {
|
|
|
+ return $this->errorResponse(message: 'Prestador não encontrado.', code: 404);
|
|
|
} catch (\Exception $e) {
|
|
|
Log::error('Erro ao obter dados do dashboard do prestador: '.$e->getMessage());
|
|
|
-
|
|
|
return $this->errorResponse(message: __('messages.error_fetching_data'), code: 500);
|
|
|
}
|
|
|
}
|