Afterware

The only difference with middlewares is that afterwares gets executed after controller action. Afterwares could be used for logging or enriching responses.

class LogEmptyRequest {
    public function execute() {
        $output = response()->getOutput();

        if ($output) {
            Foo::bar();
        }

        return $next();
    }
}

Last updated

Was this helpful?