Table of contents

Laravel Table Exists

For whatsoever reason, you may want to check the existence of a table in your database. You can easily achieve this by using one of Laravel's schema builder method hasTable(). The Laravel schema builder hasTable() method accepts one argument, the name of the table to check.


Previously I have functionality that need to check the table if exists before I generate a new table using my custom CRUD generator.


Maybe you need to check our tutorial on how to generate table fields just visit here. We use the model class to extract the table and call the fields.



if (Schema::hasTable('table_name'))
    // Do something if exists


That's a brief tip for checking table exists using Laravel. I hope it helps.

Cheers :)