我们有可以通过mysql创建的自定义字段,这些字段由模块“拥有”(例如:Opportunities-module需要“潜在销售”字段,而User-section需要性别字段(选择3个选项)。
[使用Laravel 6雄辩,我试图获取:
,然后将它们添加到集合中的“相关”数组中。这样我就可以轻松做到:
$opportunity->custom_field[x]->custom_field->name $opportunity->custom_field[x]->custom_field_value[x]->value
DB:
custom_fields: id, name, category (opportunity, client...), type (text, number, select, radio) custom_field_custom_field_value (pivot): custom_field_id, custom_field_value_id, parent_id (=id of the "parent" opportunity or client...), selected custom_field_values: id, value
我很想让自己开始,但我百分百地陷入困境-甚至不知道从哪里开始使用归属感等...或者这完全可行...
我们有可以通过mysql创建的自定义字段,这些字段由模块“拥有”(例如:Opportunities-module想要一个“潜在销售”字段,而User-section想要一个性别字段(...
class CustomField extends Model
{
public function values()
{
return $this->belongsToMany(CustomFieldValue::class);
}
}