| Total Complexity | 4 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class Translation extends Model implements TranslationContract |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The attributes that are mass assignable. |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $fillable = [ |
||
| 18 | 'language_code', |
||
| 19 | 'key', |
||
| 20 | 'value', |
||
| 21 | ]; |
||
| 22 | |||
| 23 | public function __construct(array $attributes = []) |
||
| 24 | { |
||
| 25 | if (! isset($this->table)) { |
||
| 26 | $this->setTable(config('translator.table_name')); |
||
| 27 | } |
||
| 28 | |||
| 29 | parent::__construct($attributes); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * The associated translatable relation. |
||
| 34 | * |
||
| 35 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
| 36 | */ |
||
| 37 | public function translatable(): MorphTo |
||
| 38 | { |
||
| 39 | return $this->morphTo(); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Scope a query to only include translations for a given language. |
||
| 44 | * |
||
| 45 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
| 46 | * @param string $langCode |
||
| 47 | * @return \Illuminate\Database\Eloquent\Builder |
||
| 48 | */ |
||
| 49 | public function scopeForLang(Builder $query, string $langCode): Builder |
||
| 52 | } |
||
| 53 | } |
||
| 54 |