A
A
Alexander Kovalchuk2016-05-27 20:36:41
Laravel
Alexander Kovalchuk, 2016-05-27 20:36:41

How to connect Sentinel in Laravel 5.2?

How to write gradle that will enable Sentinel authorization and authentication by default?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kovalchuk, 2016-05-29
@mamut

First you need to create a service provider that override Auth for example app/Providers/AdminServiceProvider.php
And there we connect the Sentinel class

namespace App\Providers;

    use Auth;
    use Cartalyst\Sentinel\Sentinel;
    use Illuminate\Support\ServiceProvider;

    class AdminServiceProvider extends ServiceProvider
    {
        /**
         * Bootstrap the application services.
         *
         * @return void
         */
        public
        function boot()
        {
            Auth::provider('our_provider', function($app, array $config)  {

                return new Sentinel();
            });
        }

        /**
         * Register the application services.
         *
         * @return void
         */
        public
        function register()
        {
            //
        }
    }

Next, you need to make changes toapp/config/auth.php
'providers' => [
    'users' => [
        'driver' => 'our_provider',
    ],
],

After that, everything works, of course, you can create another provider and use it if you need to use Sentinel along with another authorization method.
It is made simply elegant and very comfortable. I'm amazed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question