app/Providers/AppServiceProvider.php
/**
     * Register any application services.
     *
     * @return void
     */
Register any application services.
@return void
Register any application services . @return void
public function register()
    {
        $this->app->when(ProductController::class)
            ->needs(ProductRepository::class)
            ->give(function () {
                return new RedisProductRepository(
                    new MysqlProductRepository()
                );
            });
    }
public function register ( ) { $ this -> app -> when ( ProductController :: class ) -> needs ( ProductRepository :: class ) -> give ( function ( ) { return new RedisProductRepository ( new MysqlProductRepository ( ) ) ; } ) ; }
Register any application services.
Register any application services .