22
22
* Manages the setup and configuration of Laravel's Eloquent ORM in a CodeIgniter 4 app.
23
23
* Optimized for performance with caching and lazy loading.
24
24
*/
25
- final class EloquentDatabase
25
+ class EloquentDatabase
26
26
{
27
27
protected Container $ container ;
28
28
protected Capsule $ capsule ;
@@ -462,7 +462,7 @@ protected function getEloquentModels(): array
462
462
}
463
463
464
464
// Try APCu cache first (production only)
465
- $ cacheKey = 'eloquent_models_ ' . md5 (APPPATH . filemtime (APPPATH . 'Models ' ));
465
+ $ cacheKey = 'eloquent_models_ ' . md5 (APPPATH . filemtime (APPPATH . 'Models ' ));
466
466
if (function_exists ('apcu_fetch ' ) && ENVIRONMENT === 'production ' ) {
467
467
$ cached = apcu_fetch ($ cacheKey );
468
468
if ($ cached !== false ) {
@@ -485,13 +485,13 @@ protected function getEloquentModels(): array
485
485
*/
486
486
private function discoverModels (): array
487
487
{
488
- $ modelPath = APPPATH . 'Models/ ' ;
488
+ $ modelPath = APPPATH . 'Models/ ' ;
489
489
if (! is_dir ($ modelPath )) {
490
490
return [];
491
491
}
492
492
493
493
// Use glob for better performance than DirectoryIterator
494
- $ files = glob ($ modelPath. '*.php ' );
494
+ $ files = glob ($ modelPath . '*.php ' );
495
495
if ($ files === false ) {
496
496
return [];
497
497
}
@@ -568,19 +568,19 @@ protected function registerConfigService(): void
568
568
569
569
protected function registerDatabaseService (): void
570
570
{
571
- $ this ->container ->singleton ('db ' , fn () => $ this ->capsule ->getDatabaseManager ());
571
+ $ this ->container ->singleton ('db ' , fn () => $ this ->capsule ->getDatabaseManager ());
572
572
}
573
573
574
574
protected function registerHashService (): void
575
575
{
576
- $ this ->container ->singleton ('hash ' , fn ($ app ) => new HashManager ($ app ));
576
+ $ this ->container ->singleton ('hash ' , fn ($ app ) => new HashManager ($ app ));
577
577
}
578
578
579
579
protected function registerPaginationRenderer (): void
580
580
{
581
581
$ this ->container ->singleton (
582
582
PaginationRenderer::class,
583
- fn () => new PaginationRenderer
583
+ fn () => new PaginationRenderer
584
584
);
585
585
$ this ->container ->alias (PaginationRenderer::class, 'paginator.renderer ' );
586
586
}
@@ -601,7 +601,7 @@ protected function configurePagination(): void
601
601
602
602
$ container = $ this ->container ;
603
603
Paginator::viewFactoryResolver (
604
- fn () => $ container ->get ('paginator.renderer ' )
604
+ fn () => $ container ->get ('paginator.renderer ' )
605
605
);
606
606
607
607
Paginator::currentPageResolver (
@@ -616,8 +616,8 @@ function ($pageName = 'page') use ($request) {
616
616
}
617
617
);
618
618
619
- Paginator::currentPathResolver (fn () => current_url ());
620
- Paginator::queryStringResolver (fn () => $ uri ->getQuery ());
619
+ Paginator::currentPathResolver (fn () => current_url ());
620
+ Paginator::queryStringResolver (fn () => $ uri ->getQuery ());
621
621
622
622
CursorPaginator::currentCursorResolver (
623
623
function ($ cursorName = 'cursor ' ) use ($ request ) {
@@ -679,4 +679,4 @@ public function __destruct()
679
679
{
680
680
unset($ this ->sqliteHandler );
681
681
}
682
- }
682
+ }
0 commit comments