File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,16 @@ public function toArray($request): array
2525 ];
2626 }
2727
28- /** @var array{previous?: mixed, next?: mixed} $resource */
29- $ resource = $ this ->resource ;
28+ // Cast to proper array type for PHPStan
29+ /** @var array<string, \CSlant\Blog\Core\Models\Post|null> $navigationData */
30+ $ navigationData = $ this ->resource ;
31+
32+ $ previous = array_key_exists ('previous ' , $ navigationData ) ? $ navigationData ['previous ' ] : null ;
33+ $ next = array_key_exists ('next ' , $ navigationData ) ? $ navigationData ['next ' ] : null ;
3034
3135 return [
32- 'previous ' => isset ( $ resource [ ' previous ' ]) && $ resource [ ' previous ' ] ? new PostNavigationResource ($ resource [ ' previous ' ] ) : null ,
33- 'next ' => isset ( $ resource [ ' next ' ]) && $ resource [ ' next ' ] ? new PostNavigationResource ($ resource [ ' next ' ] ) : null ,
36+ 'previous ' => $ previous ? new PostNavigationResource ($ previous ) : null ,
37+ 'next ' => $ next ? new PostNavigationResource ($ next ) : null ,
3438 ];
3539 }
3640}
You can’t perform that action at this time.
0 commit comments