Skip to content
Advertisement

Is there any way to detect if a database table exists with Laravel

I want to be able to create a table using

Schema::create('mytable',function($table)
{
    $table->increments('id');
    $table->string('title');
});

But before that I would like to check if the table already exists, perhaps something like

Schema::exists('mytable');

However, the above function does not exist. What else can I use?

Advertisement

Answer

If you are using Laravel 4 or 5 then there is the hasTable() method, you can find it in the L4 source code or the L5 docs:

Schema::hasTable('mytable');
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement