samedi 23 janvier 2016

How to pass constructor dependency in Laravel service provider

I am registering my Social authentication service in service provider, the implementation of my interface requires parameters in its constructor function.

How to pass it via service provider? Here is my code but it's syntactically incorrect.

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use App;
use App\User;
use Illuminate\Contracts\Auth\Guard;
use Laravel\Socialite\Contracts\Factory as Socialite;

class SocialAuthenticationServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        App::bind('App\Repositories\SocialAuthenticationInterface', function () {
            return new App\Repositories\SocialAuthentication(Socialite $socialite, Guard $auth, User $user);
        });
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ThkxMR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire