Hii,
The extend method allows the modification of resolved services.
For example, when a service is resolved, you may run additional code to decorate or configure the service. The extend method accepts a Closure, which should return the modified service, as its only argument:
$this->app->extend(Service::class, function($service) {
return new DecoratedService($service);
});
The above code will help you to modify the already resolved services.
To extend the Laravel cache facility, we will use the extend method on the CacheManager, which is used to bind a custom driver resolver to the manager, and is common across all manager classes. For example, to register a new cache driver named "mongo", we would do the following:
Cache::extend('mongo', function($app)
{
// Return Illuminate\Cache\Repository instance...
});
Thank you!