If you want to build an web app for user to install just like wordpress only click on UI you may want to check the existing table in you database, or before doing something else with the table. You can check by using schema builder method hasTable() which is accepted table's name as argument.
You can use this example with the versions of laravel 6, laravel 7, laravel 8, and laravel 9.
Please skip this step if you have installed Laravel, if not then you have to run below command to dowload Laravel project.
composer create-project laravel/laravel blog
By default in Laravel have a controller named HomeController.php
Open file App/Http/Controllers/HomeController.php
<?php
namespace App\Http\Controllers;
class HomeController extends Controller
{
public function index()
{
if (Schema::hasTable('your_table'))
{
// Do some code here
print("Yes existing table");
}
}
}
Output:
Yes existing table
Hope this short article help you to check table in database. Have a nice day!!
You might also like...
As the founder and passionate educator behind this platform, I’m dedicated to sharing practical knowledge in programming to help you grow. Whether you’re a beginner exploring Machine Learning, PHP, Laravel, Python, Java, or Android Development, you’ll find tutorials here that are simple, accessible, and easy to understand. My mission is to make learning enjoyable and effective for everyone. Dive in, start learning, and don’t forget to follow along for more tips and insights!. Follow him