-
I would like to add some global settings inside the admin panel that can be changed anytime and will also be cached. I haven't found anything in the docs about it. So I guess I have to write something on my own and bypass the orchid logic? Or did I miss some package for that? Like a Model that defines all settings/options for dropdowns, ... and maybe a screen to render it in the preferred way? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
what kind of global settings do you need, does normal laravel config doesn't fit your needs ? |
Beta Was this translation helpful? Give feedback.
-
Settings that can be changed by a few users with permissions inside the app but no server access. No need to change .env file on the server or do a deployment for other config files. Right now I would like to set a default PDF split value. User selects products, wants to print the production labels and will get PDF downloads. If the amount of products is high, they should be splitted into multiple PDF files. It's already implemented but with hardcoded value for tests only. Now I could add it to the laravel config and maybe use the .env but It would be better to have a settings screen for such things. Or a setting to enable/disable the PDF splittitng. There are many situations where I would like to have a settings screen like in many other web apps. Until now I tried to avoid it. |
Beta Was this translation helpful? Give feedback.
-
It sounds like you want to create a custom settings page in the Laravel Orchid admin panel where you can define and manage global settings that will be cached. In order to do this, you will need to create a custom model to store your settings data, as well as a custom controller and view to handle the settings page in the admin panel. To create the custom model, you can use the php artisan make:model command to generate a new model class. For example, you might create a model called Settings that has a key and a value attribute. Once you have your model set up, you can create a view to display the settings page in the admin panel. This view should use the Laravel Orchid components and layout to match the look and feel of the rest of the admin panel. It is also worth mentioning that Laravel provides a built-in Cache facade that you can use to easily cache your settings data and retrieve it later. This can be useful if you want to make sure that your settings are always up-to-date and available to your application. Overall, creating a custom settings page in the Laravel Orchid admin panel is a fairly straightforward process, but it will require some custom coding to get everything set up and working properly. I also recommend looking at existing packages such as https://github.com/tabuna/settings or the more recent https://github.com/spatie/laravel-settings
|
Beta Was this translation helpful? Give feedback.
-
Thanks, spatie/laravel-settings was already on my list to check after some google search. Wasn't sure if it would be possible to get it inside orchid working since the saving should be different from normal models. Missing abit of an validation logic and a few other things but I think it would be ok for us for now. |
Beta Was this translation helpful? Give feedback.
-
"Right now I would like to set a default PDF split value......" you can have a entity/model say SettingModel that abstracts a configurations table, then you can group a set of settings namekeying it by a key name field, and all settings stored as a JSON per record so then a record with a key like "pdf-settings" and a value in JSON format stored in that model like {"bar": "foo", "pagination": "10"} will work really nice, and then just build your own screen with a form with the components you want to fill the settings values once again using https://github.com/glorand/laravel-model-settings you can the create a laravel helper function that wraps the retrieving record and the $settingModel->settings()->get('some.value'); call to return the value or values you need globally in you codebase It really fits your need as far as I read you that way GUI user setted dynamic configs (production running time) are stored as it should instead of modifying json or XML files wich is something I don't recommend unless they are fixed settings at solution deploying time. |
Beta Was this translation helpful? Give feedback.
It sounds like you want to create a custom settings page in the Laravel Orchid admin panel where you can define and manage global settings that will be cached.
In order to do this, you will need to create a custom model to store your settings data, as well as a custom controller and view to handle the settings page in the admin panel.
To create the custom model, you can use the php artisan make:model command to generate a new model class. For example, you might create a model called Settings that has a key and a value attribute.
Once you have your model set up, you can create a view to display the settings page in the admin panel. This view should use the Laravel Orchid components and lay…