In Laravel 10+ , you can share data with all 404 error views using View Composers in AppServiceProvider.php like this:
View::composer('errors::404', function ($view) { $view->with('data', $data); });