Laravel Basic Usage - Dependency Injection


Example

/**
 * LoginController constructor.
 * @param Socialite $socialite
 */
public function __construct(Socialite $socialite) {
    $this->socialite = $socialite;
}

Within the constructor of your Controller, you're now able to inject the Socialite class that will help you handle login with social networks. This will replace the usage of the Facade.

/**
 * Redirects the User to the Facebook page to get authorization.
 *
 * @return Response
 */
public function facebook() {
    return $this->socialite->driver('facebook')->redirect();
}