This is classic behavior of PHP loading the compiled files from memory instead of reading your disk changes. Since your error page preview shows the updated code but the execution is using the old logic, it essentially guarantees this is an in-memory caching issue.
OPcache is overly aggressive
Run php --ini in your terminal to find out which config file your CLI is using. Open it up and look for your OPcache block. For a local dev environment, OPcache should ideally be disabled, or at the very least, configured to check for file changes instantly.
Make sure your settings look like this:
opcache.enable=1
opcache.enable_cli=1
opcache.validate_timestamps=1 ; This is the crucial one. If set to 0, it never checks for updates.
opcache.revalidate_freq=0 ; Forces it to check on every single request.
Note: Alternatively, just set opcache.enable=0 and opcache.enable_cli=0 for local dev to bypass it entirely.
You're running Laravel Octane If you are serving the application using Laravel Octane (FrankenPHP, Swoole, or RoadRunner), the entire framework is booted into RAM once. Changes to controllers, middleware, or service providers will never reflect until the server restarts.
If this is your stack, you must start the server with the watch flag so it auto-reloads on file saves:
php artisan octane:start --watch
Check that php.ini first. 99% of the time, validate_timestamps got toggled off or you installed a pre-configured PHP package on CachyOS that optimized it for production by default.