|
@@ -6,6 +6,7 @@ use App\Http\Requests\AppointmentRequest;
|
|
|
use App\Http\Resources\AppointmentResource;
|
|
use App\Http\Resources\AppointmentResource;
|
|
|
use App\Services\AppointmentService;
|
|
use App\Services\AppointmentService;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
+use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
|
|
class AppointmentController extends Controller
|
|
class AppointmentController extends Controller
|
|
@@ -54,4 +55,48 @@ class AppointmentController extends Controller
|
|
|
$this->service->delete($id);
|
|
$this->service->delete($id);
|
|
|
return $this->successResponse(message: __('messages.deleted'), code: 204);
|
|
return $this->successResponse(message: __('messages.deleted'), code: 204);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function getAdminCounters(): JsonResponse
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->successResponse(payload: $this->service->getAdminCounters());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function getAdminAppointmentsPaginated(Request $request): JsonResponse
|
|
|
|
|
+ {
|
|
|
|
|
+ $filters = $request->only(['status', 'search']);
|
|
|
|
|
+ $perPage = (int) $request->input('per_page', 10);
|
|
|
|
|
+ $paginator = $this->service->getAllPaginated($filters, $perPage);
|
|
|
|
|
+
|
|
|
|
|
+ $items = collect($paginator->items())->map(fn($a) => [
|
|
|
|
|
+ 'id' => $a->id,
|
|
|
|
|
+ 'order_number' => $a->order_number,
|
|
|
|
|
+ 'registration' => $a->user?->registration,
|
|
|
|
|
+ 'user_name' => $a->user?->name,
|
|
|
|
|
+ 'partner_name' => $a->partnerAgreement?->trade_name ?? $a->partnerAgreement?->company_name,
|
|
|
|
|
+ 'service_name' => $a->partnerAgreementService?->name,
|
|
|
|
|
+ 'requested_at' => $a->requested_at?->format('d/m/Y'),
|
|
|
|
|
+ 'status' => $a->status?->value,
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ return $this->successResponse(payload: [
|
|
|
|
|
+ 'data' => $items,
|
|
|
|
|
+ 'total' => $paginator->total(),
|
|
|
|
|
+ 'per_page' => $paginator->perPage(),
|
|
|
|
|
+ 'current_page' => $paginator->currentPage(),
|
|
|
|
|
+ 'from' => $paginator->firstItem(),
|
|
|
|
|
+ 'to' => $paginator->lastItem(),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function approve(int $id): JsonResponse
|
|
|
|
|
+ {
|
|
|
|
|
+ $item = $this->service->approve($id);
|
|
|
|
|
+ return $this->successResponse(payload: new AppointmentResource($item), message: __('messages.updated'));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function reject(int $id): JsonResponse
|
|
|
|
|
+ {
|
|
|
|
|
+ $item = $this->service->reject($id);
|
|
|
|
|
+ return $this->successResponse(payload: new AppointmentResource($item), message: __('messages.updated'));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|