platform icon indicating copy to clipboard operation
platform copied to clipboard

Reduce the number of files for customization

Open tabuna opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

At the moment, many settings are defined in the configuration file located in config/platform.php, but the part expects you to define in the service provider. For example, the following settings can be found in the default file App\Orchid\PlatformProvider:

/**
 * @return ItemPermission[]
 */
public function registerPermissions(): array
{
    return [
        ItemPermission::group(__('System'))
            ->addPermission('platform.systems.roles', __('Roles'))
            ->addPermission('platform.systems.users', __('Users')),
    ];
}

/**
 * @return string[]
 */
public function registerSearchModels(): array
{
    return [
        // ...Models
        // \App\Models\User::class
    ];
}

Describe the solution you'd like

Let us combine them into the main file to cause as little confusion as possible. The only thing that confuses me is the translation definition for groups and permissions. Since we cannot call the __ () function in the configuration file (the result of the file will be cached). This means that the definition of the translation for these lines will become less explicit and dynamic when displayed.

After the transfer, we can rename the App\Orchid\PlatformProvider to something more understandable for a beginner, for example App\Orchid\MenuProvider, since only the methods responsible for the menu will remain in it.

tabuna avatar Aug 18 '21 13:08 tabuna

once again for the permission i realy recomend something like what i proposed here: https://github.com/orchidsoftware/platform/discussions/1523

lemyskaman avatar Aug 19 '21 14:08 lemyskaman

Since we cannot call the __ ()

You can use the trans() helper https://laravel.com/docs/8.x/helpers#method-trans in the config files.

ShamarKellman avatar Aug 25 '21 01:08 ShamarKellman

@ShamarKellman When doing caching, this will be executed and lead to the same problem as using __().

tabuna avatar Aug 25 '21 01:08 tabuna