How to Check Table is Exists or Not in Laravel?

Dec 12, 2022



How to Check Table is Exists or Not in Laravel?

Hello Friends,

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.

You can use this example with the versions of laravel 6, laravel 7, laravel 8, and laravel 9.

Install Laravel

This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

You might want to check out our lesson on creating table fields by clicking here. To extract the table and call the fields, we employ the model class.



namespace App\Http\Controllers;

class ProductController extends Controller



* Write code on Method


* @return response()


public function index()


if (Schema::hasTable('table_name'))


dd('Table Exist...');





Table Exist...

I hope it can help you...