samedi 29 août 2020

How to bind or inject variables from service providers to model class laravel

I have this class called Book and I want to have one global variable sort of thing in that class which consist of a exchange rate (For whole data / model) I am trying to use service containers to inject the variable in it but I am sort of loss here

I tried this code in my AppServiceProvider.php in register()

$variable = 'something';
$this->app->bind('App\Models\FrontEnd\Book', function ($app) {
    return new $variable;
});

But it does not work .



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2EMg2f7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire