A couple of days ago I saw a message on Laravel Internals from asking about intercepting data passed from controllers to the view. Here is how I did it. Colin Viebrock 1- Extend the ViewServiceProvider Using artisan we can just to get us started. In the new service provider, we’re going to extend the default one and simply override the method php artisan make:provider ViewServiceProvider createFactory **<?php namespace** App\Providers; App\Support\View\MyViewFactory; Illuminate\View\ViewServiceProvider BaseViewServiceProvider; use use as ViewServiceProvider BaseViewServiceProvider{ createFactory($resolver, $finder, $events){ MyViewFactory($resolver, $finder, $events);}} class extends protected function return new 2- Don’t forget to swap the Service Provider settings Inside the there’s a list of providers that will boot up. Let’s remove the default one and replace it with the one we created on step 1. Should be . application/config/app.php Illuminate \App\Providers\ViewServiceProvider 3- Create the custom View Factory I decided to create mine in as follows: application/App/Support/View **<?php namespace** App\Support\View; Illuminate\View\Factory; use MyViewFactory Factory{ viewInstance($view, $path, $data){ MyView($this, $this->getEngineFromPath($path), $view, $path, $data);}} class extends protected function return new 4- Implement data interception in your custom View The method will be called right before providing data to views. That is the perfect place to intercept all of the data provided. gatherData **<?php namespace** App\Support\View; Illuminate\View\View; use MyView View{ gatherData(){$data = :: (); class extends protected function parent gatherData **return** array\_merge($data, \['intercepted' => **true**\]); } } 5- See the result! Now just open the file and add a snippet that allows you to test the interception: welcome.blade.php $intercepted**)** <h1>INTERCEPTED!</h1> @if( @endif And you’ll be able to see it once you open the page.