The optional function accepts any argument and allows you to access properties or call methods on that object. If the given object is null, properties and methods will return null instead of causing an error:
<?php return optional($user->address)->street;

{!! old('name', optional($user)->name) !!}
<?php         $route = $this->request->route();



        return [

            'route' => optional($route)->getName(),

            'routeParameters' => $this->getRouteParameters(),

            'controllerAction' => optional($route)->getActionName(),

            'middleware' => array_values(optional($route)->gatherMiddleware() ?? []),
<?php         return [

            'route' => optional($route)->getName(),

            'routeParameters' => $this->getRouteParameters(),

            'controllerAction' => optional($route)->getActionName(),

            'middleware' => array_values(optional($route)->gatherMiddleware() ?? []),

        ];

    }
<?php             'route' => optional($route)->getName(),

            'routeParameters' => $this->getRouteParameters(),

            'controllerAction' => optional($route)->getActionName(),

            'middleware' => array_values(optional($route)->gatherMiddleware() ?? []),

        ];

    }
<?php     protected function getRouteParameters(): array

    {

        try {

            return collect(optional($this->request->route())->parameters ?? [])->toArray();

        } catch (Throwable $e) {

            return [];

        }