Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow a different table for the Translation model #428

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/translation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@
],

/**
* Database connection name to allow for different db connection for the translations table.
* Database table and connection name to allow for different db connection for the translations table.
*/
'db_table' => env('TRANSLATION_MANAGER_DB_TABLE', null),
'db_connection' => env('TRANSLATION_MANAGER_DB_CONNECTION', null),

];
14 changes: 14 additions & 0 deletions src/Models/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ public function scopeSelectDistinctGroup($query)
return $query->select(DB::raw($select));
}

/**
* Get the table associated with the model.
*
* @return string
*/
public function getTable()
{
if ($table = config('translation-manager.db_table')){
return $table;
}

return parent::getTable();
}

/**
* Get the current connection name for the model.
*
Expand Down