How to use global prefix for tables in Laravel 8

How to use global prefix for tables in Laravel 8

August 1, 2021 | 1 min read

Laravel caches config files, so you may simply need to clear the cache:

php artisan config:clear

In addition to this, a better practice is to use the .env file to define your prefix, like this:

DB_PREFIX=admin_

and loading that in your config file, like this:

'prefix' => env('DB_PREFIX', 'admin_')

This is how it should have been by default.

SECOND METHOD

Add profix directly in app/config/database.php

'prefix' => 'thj_',