Skip to content

Instantly share code, notes, and snippets.

@vanchelo
Created February 8, 2015 21:56
Show Gist options
  • Save vanchelo/99542705ec0d6296f741 to your computer and use it in GitHub Desktop.
Save vanchelo/99542705ec0d6296f741 to your computer and use it in GitHub Desktop.
<?php namespace Backend\Auth;
use Illuminate\Auth\AuthManager as BaseAuthManager;
use Illuminate\Auth\EloquentUserProvider;
class AuthManager extends BaseAuthManager
{
/**
* Create an instance of the Eloquent driver.
*
* @return \Illuminate\Auth\Guard
*/
public function createEloquentDriver()
{
$provider = $this->createEloquentProvider();
return new Guard($provider, $this->app['session.store']);
}
/**
* Create an instance of the Eloquent user provider.
*
* @return \Illuminate\Auth\EloquentUserProvider
*/
protected function createEloquentProvider()
{
$model = $this->app['config']->get('auth.model');
return new EloquentUserProvider($this->app['hash'], $model);
}
/**
* Get the default authentication driver name.
*
* @return string
*/
public function getDefaultDriver()
{
return 'eloquent';
}
}
<?php namespace Backend\Auth;
use Illuminate\Support\ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bindShared('backend.auth', function ($app)
{
return new AuthManager($app);
});
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['backend.auth'];
}
}
<?php namespace Backend\Auth\Facades;
use Illuminate\Support\Facades\Facade;
/**
* @see \Illuminate\Auth\AuthManager
* @see \Illuminate\Auth\Guard
*/
class Auth extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'backend.auth';
}
<?php namespace Backend\Auth;
class Guard extends \Illuminate\Auth\Guard
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment