kodeine / laravel-meta

Fluent Meta Data for Eloquent Models, as if it is a property on your model
MIT License
400 stars 90 forks source link

Adding the ability to have override `key` and `value` column names #113

Closed andy-UKC closed 4 months ago

andy-UKC commented 4 months ago

To override the key and value column in the _meta table, the following can be used

protected $metaValueColumnName = 'meta_value'; //default is `value`

protected $metaKeyColumnName = 'meta_key'; //default is `key`
andy-UKC commented 4 months ago

The Metable.php file followed the conventions used elsewhere, but I had to create an init() function in MetaData.php, and call it when creating the class in Metable. There may be a better way to handle passing of the value column, feel free to refactor it

siamak2 commented 4 months ago

This PR has many problems. The init method in MetaData.php never gets called. In MetaData.php we have a mutator for value column that will call the setValueAttribute method in MetaData.php. Changing the column name for value will result in this mutator never getting called. Since we're defining the key and value column names in the model that has the Metable trait, and there is no direct relation between MetaData and other models, it's impossible to know what the key and value are in MetaData.

What is the purpose of this PR?