Not able to add unique to products table through Laravel migration
<p><a href="https://i.stack.imgur.com/KrP2C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KrP2C.png" alt="enter image description here"></a></p>

<p>I am trying to add <code>unique</code> to <code>slug</code> in products table and I have the following migration. However when I run <code>php artisan migrate</code> I get an error.</p>

<pre><code>use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddUniqueToProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('products', function (Blueprint $table) {
           $table-&gt;unique('slug'); 
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('products', function (Blueprint $table) {
            $table-&gt;dropUnique('products_slug_unique');
        });
    }
}
</code></pre>

<p>Error</p>

<blockquote>
  <p>➜ php artisan migrate</p>
  
  <p>[Illuminate\Database\QueryException]   SQLSTATE[23000]: Integrity
  constraint violation: 1062 Duplicate entry '' for key
  'products_slug_unique' (SQL: alter table <code>products</code> add    unique
  <code>products_slug_unique</code>(<code>slug</code>))</p>
  
  <p>[Doctrine\DBAL\Driver\PDOException]   SQLSTATE[23000]: Integrity
  constraint violation: 1062 Duplicate entry '' for key
  'products_slug_unique'</p>
  
  <p>[PDOException]   SQLSTATE[23000]: Integrity constraint violation:
  1062 Duplicate entry '' for key 'products_slug_unique'</p>
</blockquote>

<p>What am I doing wrong here?</p>