haruncpi/laravel-option-framework

Option by group?

dmason30 opened this issue · 2 comments

Thanks for the great package but for me there is one thing holding me back from using it.

I am currently developing a white-label product so obviously this requires much of the application to be configurable and I am currently researching the best solution for this.

I would like to keep setting names consistent see below example config:

<?php
return array(
    array(
        "id" => "general",
        "label" => "General",
        "icon" => "fa-cubes",
        "fields" => array(
            array(
                "type" => "text",
                "id" => "name",
                "label" => "Name",
                "description" => "Enter your site name",
                "icon" => "fa-globe",
                "validation" => 'required|min:10'
            ),
        )
    ),
    array(
        "id" => "client",
        "label" => "Client",
        "icon" => "fa-globe",
        "fields" => array(
            array(
                "type" => "text",
                "id" => "name",
                "label" => "Name",
                "description" => "Enter client name",
                "icon" => "fa-people"
            )
        )
    )
);

Now with the way the package works the above config is incorrect would have side effects since multiple settings have the same name.

Since the groups already have an id I was wandering if you would consider adding a group column to the options table and changing the functions to optionally save the group with the setting:

function getOption($optionName, $group = null)
function optionExist($optionName, $group = null)
function createOption($optionName, $optionValue, $group = null)
function updateOption($optionName, $optionValue, $group = null)
function deleteOption($optionName, $group = null)

Also I feel like createOption and updateOption are redundant and should be replaced with a saveOption that does an updateOrCreate under the hood.

You can consider to use prefix.
Example
Group id client then fields

client_id
client_name
...

The whole point in the above was to avoid using a prefix.