jeudi 21 février 2019

Laravel: how to access a variable in the AppServiceProvider from a Helper file?

I had to declare a variable in AppServiceProvider and shared it to all view to be able to use it everywhere.

AppServiceProvider.php

//the reputation variable
        $reputations = array(
            'xxx'=>array('value'=>1,'description'=>'yyy')
        );

        view()->share([
            'reputations'=>$reputations]);

now I have a helper file that has some functions also available in all views and controllers. I wish to access the $reputations variable inside Helpers.php

App\Helpers\Helpers.php



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire