Don't use a global prefix, but use a custom table name per model instead :
class Group extends Eloquent {
protected $table = 'myprefix_group';
}
I haven't fully implemented this yet but this is what I've got going.
I have a config value for the db.prefix
then for migrations
public function __construct()
{
// Get the prefix
$this->prefix = Config::get('db.prefix', '');
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Schema::table('users', function(Blueprint $table)
Schema::table($this->prefix . 'users', function(Blueprint $table)
{
//
});
}
In the model
protected $table = Config::get('db.prefix', '') . 'users';
If you use raw queries in your model/repositories don't forget to include the config value there too.
IF you add it to the config/database.php file then all your tables will have the prefix. So, I assign them independently. It's more work but you get finer control.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community