Skip to content

change in transaction table name & databae connection #411

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

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
5 changes: 5 additions & 0 deletions config/translation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
*/
'exclude_groups' => [],

'database' => [
'table' => env('TRANSLATION_TABLE_NAME', 'ltm_translations'),
'connection' => env('TRANSLATION_CONNECTION', 'mysql'),
],

/**
* Exclude specific languages from Laravel Translation Manager.
*
Expand Down
37 changes: 25 additions & 12 deletions src/Models/Translation.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
<?php namespace Barryvdh\TranslationManager\Models;
<?php

use Illuminate\Database\Eloquent\Model;
namespace Barryvdh\TranslationManager\Models;

use App\Models\BaseModel;
use DB;
use Illuminate\Database\Eloquent\Model;

/**
* Translation model
* Translation model.
*
* @property integer $id
* @property integer $status
* @property int $id
* @property int $status
* @property string $locale
* @property string $group
* @property string $key
* @property string $value
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*/
class Translation extends Model{
class Translation extends BaseModel
{
public const STATUS_SAVED = 0;

const STATUS_SAVED = 0;
const STATUS_CHANGED = 1;
public const STATUS_CHANGED = 1;

protected $table = 'ltm_translations';
protected $guarded = array('id', 'created_at', 'updated_at');

protected $connection = 'mysql';

public function __construct()
{
$this->connection = config('translation-manager.database.connection');
$this->table = config('translation-manager.database.table');
}

protected $guarded = ['id', 'created_at', 'updated_at'];

public function scopeOfTranslatedGroup($query, $group)
{
return $query->where('group', $group)->whereNotNull('value');
}

public function scopeOrderByGroupKeys($query, $ordered) {
public function scopeOrderByGroupKeys($query, $ordered)
{
if ($ordered) {
$query->orderBy('group')->orderBy('key');
}
Expand All @@ -40,7 +54,7 @@ public function scopeSelectDistinctGroup($query)
{
$select = '';

switch (DB::getDriverName()){
switch (DB::getDriverName()) {
case 'mysql':
$select = 'DISTINCT `group`';
break;
Expand All @@ -51,5 +65,4 @@ public function scopeSelectDistinctGroup($query)

return $query->select(DB::raw($select));
}

}