PASSWORD RESET

Your destination for complete Tech news

How to check if a database table exists in Laravel?

1K 0
< 1 min read

In Laravel, you can check if a database table exists using the Schema facade.

Here’s an example:

use Illuminate\Support\Facades\Schema;

if (Schema::hasTable('table_name')) {
    // Do something if the table exists
} else {
    // Do something else if the table doesn't exist
}

If the table exists, the hasTable() method will return true, otherwise it will return false.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.