rainlab/translate-plugin

Can't use 'model' word as field name.

Closed this issue · 1 comments

Hello, guys!

Checked on October 1.x, October 2.x, issue exist.

Translate plugin cause error due create or update models items in backend if there is a DB field with name 'model'. In my case it was Vehicle management with typical fields: name, make, model, color, etc.
Error:
"Cannot access protected property RainLab\Translate\Behaviors\TranslatableModel::$model" on line 456 of **********/vendor/october/rain/src/Extension/ExtendableTrait.php
Steps to reproduce:

  1. Create a new model or add field with name 'model' to DB in existing model.
  2. Add this field to $translatable = ['model'];
  3. Try to create or update model item;
  4. After click on 'Save' button there is an error described above.

Hello @iMateo

The word model is reserved and cannot be used as a model attribute in this context. There are others, including table, connection, with, dates, exists, hidden ... and is a known limitation with Laravel's eloquent design.

This is part of the core design that spreads across all model behaviors within the system and cannot be changed without significant refactor: https://github.com/octobercms/library/blob/develop/src/Database/ModelBehavior.php

The solution might be to use a more descriptive column name such as model_name

I hope this helps