title: How to drop a database in Laravel 6?
body: <p>So I have an issue where I have a multi-tenant application, and I have a system where I can manage all of these tenants with standard CRUD operations. I want to be able to drop the tenant databases when the tenant gets deleted but I cannot seem to find anything in the documentation about being able to do this, nor can I find a series of methods in the API documentation which can be used.</p>
  
  <p>I have seen the below online (the only information I can find), but it's 2 years old but all of these methods have either been deprecated or have been moved in Laravel 6.</p>
  
  <pre class="lang-php prettyprint-override"><code>Schema::getConnection()-&gt;getDoctrineSchemaManager()-&gt;dropDatabase("`{$database_name}`");
  </code></pre>
  
  <p>Through my own tests, running the following command does work.</p>
  
  <pre class="lang-php prettyprint-override"><code>DB::statement('DROP DATABASE `foo`');
  </code></pre>
  
  <p>What I can't do though is bind a variable to this statement:</p>
  
  <pre class="lang-php prettyprint-override"><code>DB::statement(DB::raw('DROP DATABASE ?', $database_name));
  </code></pre>
  
  <p>I also want to use the standard Laravel query builder instead of sanitising the information myself. So ideally I would like to be able to do something like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>DatabaseManager::dropDatabase($database_name);
  </code></pre>
  
  <p>or this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$database = DatabaseManager::connect($database_name);
  $database-&gt;dropDatabase();
  </code></pre>
  
  <p>My guess would be that I need to create a new connection to <strong>MySQL</strong> where I'm not connecting directly to an individual database. Then execute a command to drop a database, and then close the connection.</p>
  
  <p>I will be looking to build this myself, but just wondering if anyone had any thoughts on this one, or if anyway has done this before? All help is much appreciated.</p>