title: Custom class and ServiceProvider - Laravel 5.4
body: <p>I try to make a new custom class in laravel 5.4 to check the user type. </p>
  
  <p>I add this new class in a new folder app\ItSolution, code:</p>
  
  <pre><code>&lt;?php
  
  namespace App\ItSolution;
  
  class DemoClass {
  
  
      public function getPermission() {
          switch(Auth::user()-&gt;user_type_id) {
              case 1:
                  return 'admin';
                  break;
              case 2:
                  return 'promoter';
                  break;
              case 3:
                  return 'customer';
                  break;
              default:
                  return false;
          }
      }
  }
  </code></pre>
  
  <p>I want to use this class in all my app , so i try to make a new ServiceProvider, code :</p>
  
  <pre><code>&lt;?php
  
  namespace App\Providers;
  
  use Illuminate\Support\ServiceProvider;
  use App;
  
  class AuthLibServiceProvider extends ServiceProvider
  {
      /**
       * Bootstrap the application services.
       *
       * @return void
       */
      public function boot()
      {
          //
      }
  
      /**
       * Register the application services.
       *
       * @return void
       */
      public function register()
      {
         App::bind('democlass', function()
          {
              return new \App\ItSolution\DemoClass;
          });
      }
  }
  </code></pre>
  
  <p>And i make a new facade for my class in the same folder app\ItSolution, code:</p>
  
  <pre><code>&lt;?php
  
  namespace App\ItSolution;
  use Illuminate\Support\Facades\Facade;
  
  class DemoClassFacade extends Facade {
      protected static function getFacadeAccessor() { return 'democlass'; }
  }
  </code></pre>
  
  <p>After that i add this line in app/config.php </p>
  
  <pre><code>'aliases' =&gt; [
  ...
  'DemoClass'=&gt; App\ItSolution\DemoClassFacade::class,
  ]
  
  
  
  'providers' =&gt; [
      ...
      App\Providers\AuthLibServiceProvider::class,
      ]
  </code></pre>
  
  <p>But i have this error when i try to use the DemoClass alias in my controller 
  DemoClass::getPermission():</p>
  
  <blockquote>
    <p>Class 'App\Http\Controllers\DemoClass' not found</p>
  </blockquote>
  
  <p>How can i fix that please, Thnaks.</p>