/**
  * Handle the command.
  *
  * @param ApplicationRepository $applications
  */
 public function handle(ApplicationRepository $applications)
 {
     if ($applications->findByDomain(env('APPLICATION_DOMAIN'))) {
         return;
     }
     $applications->create(['name' => env('APPLICATION_NAME'), 'reference' => env('APPLICATION_REFERENCE'), 'domain' => env('APPLICATION_DOMAIN'), 'enabled' => true]);
 }
 /**
  * Locate the app by request or passed
  * variable and set the application reference.
  *
  * @return bool
  */
 public function locate()
 {
     if (app('db')->getSchemaBuilder()->hasTable('applications')) {
         if ($app = $this->applications->findByDomain(app('request')->root())) {
             $this->installed = true;
             $this->reference = $app->reference;
             return true;
         }
         return false;
     }
     return true;
 }