• Stars
    star
    267
  • Rank 149,450 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 16 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Laravel Nova tool for editing custom settings using native Nova fields.

Nova Settings

Latest Version on Packagist Total Downloads

This Laravel Nova package allows you to create custom settings in code (using Nova's native fields) and creates a UI for the users where the settings can be edited.

Requirements

  • php: >=8.0
  • laravel/nova: ^4.26

Features

  • Settings fields management in code
  • UI for editing settings
  • Helpers for accessing settings
  • Rule validation support

Screenshots

Settings View

Installation

Install the package in a Laravel Nova project via Composer and run migrations:

# Install nova-settings
composer require outl1ne/nova-settings

# Run migrations
php artisan migrate

Register the tool with Nova in the tools() method of the NovaServiceProvider:

// in app/Providers/NovaServiceProvider.php

public function tools()
{
    return [
        // ...
        new \Outl1ne\NovaSettings\NovaSettings
    ];
}

Usage

Registering fields

Define the fields in your NovaServiceProvider's boot() function by calling NovaSettings::addSettingsFields().

// Using an array
\Outl1ne\NovaSettings\NovaSettings::addSettingsFields([
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number'),
]);

// OR

// Using a callable
\Outl1ne\NovaSettings\NovaSettings::addSettingsFields(function() {
  return [
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number'),
  ];
});

Registering field panels

// Using an array
\Outl1ne\NovaSettings\NovaSettings::addSettingsFields([
    Panel::make('Panel Title', [
      Text::make('Some setting', 'some_setting'),
      Number::make('A number', 'a_number'),
    ]),
]);

Casts

If you want the value of the setting to be formatted before it's returned, pass an array similar to Eloquent's $casts property as the second parameter.

\Outl1ne\NovaSettings\NovaSettings::addSettingsFields([
    // ... fields
], [
  'some_boolean_value' => 'boolean',
  'some_float' => 'float',
  'some_collection' => 'collection',
  // ...
]);

Subpages

Add a settings page name as a third argument to list those settings in a custom subpage.

\Outl1ne\NovaSettings\NovaSettings::addSettingsFields([
    Text::make('Some setting', 'some_setting'),
    Number::make('A number', 'a_number'),
], [], 'Subpage');

If you leave the custom name empty, the field(s) will be listed under "General".

To translate the page name, publish the translations and add a new key novaSettings.$subpage to the respective translations file, where $subpage is the name of the page (full lowercase, slugified).

Authorization

Show/hide all settings

If you want to hide the whole Settings area from the sidebar, you can authorize the NovaSettings tool like so:

public function tools(): array
{
    return [
        NovaSettings::make()->canSee(fn () => user()->isAdmin()),
    ];
}

Show/hide specific setting fields

If you want to hide only some settings, you can use ->canSee(fn () => ...) per field. Like so:

Text::make('A text field')
  ->canSee(fn () => user()->isAdmin()),

Helper functions

nova_get_settings($keys = null, $defaults = [])

Call nova_get_settings() to get all the settings formated as a regular array. Additionally, you can pass a key => value array as a second argument: nova_get_settings(['some_key], ['some_key' => 'default_value']).

nova_get_setting($key, $default = null)

To get a single setting's value, call nova_get_setting('some_setting_key'). It will return either a value or null if there's no setting with such key.

You can also pass default value as a second argument nova_get_setting('some_setting_key', 'default_value'), which will be returned, if no setting was found with given key.

nova_set_setting_value($key, $value = null)

Sets a setting value for the given key.

Configuration

The config file can be published using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaSettings\NovaSettingsServiceProvider" --tag="config"
Name Type Default Description
base_path String nova-settings URL path of settings page.
reload_page_on_save Boolean false Reload the entire page on save. Useful when updating any Nova UI related settings.
models.settings Model Settings::class Optionally override the Settings model.

The migration can also be published and overwritten using:

php artisan vendor:publish --provider="Outl1ne\NovaSettings\NovaSettingsServiceProvider" --tag="migrations"

Localization

The translation file(s) can be published by using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaSettings\NovaSettingsServiceProvider" --tag="translations"

You can add your translations to resources/lang/vendor/nova-settings/ by creating a new translations file with the locale name (ie et.json) and copying the JSON from the existing en.json.

Credits

License

Nova Settings is open-sourced software licensed under the MIT license.

More Repositories

1

nova-multiselect-field

A Laravel Nova package that adds a multiselect to Nova's arsenal of fields.
PHP
325
star
2

nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag & drop.
Vue
273
star
3

nova-menu-builder

This Laravel Nova package allows you to create and manage menus and menu items.
PHP
233
star
4

nova-translatable

A Laravel Nova package that allows you to make any input field translatable.
PHP
189
star
5

nova-page-manager

Static page and region manager for Laravel Nova - designed for headless CMS's.
PHP
176
star
6

nova-simple-repeatable

A Laravel Nova simple repeatable rows field.
Vue
73
star
7

nova-detached-filters

This Laravel Nova package allows you to detach filters from the filter dropdown and show them on a card
PHP
58
star
8

nova-tailwind

This Laravel Nova package loads the full Tailwind CSS in the Nova admin panel.
JavaScript
56
star
9

nova-media-field

Simple media field with multiple image support, image browsing and thumbnail generation
Vue
55
star
10

nova-notes-field

This Laravel Nova package adds a notes field to Nova's arsenal of fields.
PHP
49
star
11

nova-media-hub

This Laravel Nova package allows you to manage media and media fields.
PHP
44
star
12

nova-table-field

Table field for Laravel Nova
Vue
40
star
13

nova-translations-loader

This package helps with loading translations inside a Nova package.
PHP
39
star
14

nova-multiselect-filter

Multiselect filter for Laravel Nova.
Vue
38
star
15

nova-blog

A Laravel Nova package that allows you to create a blog, manage blogposts and posts' content.
PHP
36
star
16

nova-drafts

A Laravel Nova package that allows you to make drafts of your current resources.
PHP
29
star
17

nova-color-field

A Laravel Nova package that adds a color picker to Nova's arsenal of fields.
Vue
26
star
18

nova-input-filter

Simple Laravel Nova input filter. Works as additional search field out of the box.
PHP
22
star
19

laravel-scout-batch-searchable

This Laravel package allows for batching of Scout updates.
PHP
18
star
20

nova-locale-field

A Laravel Nova field that allows you to manage multiple localisations of a model.
Vue
17
star
21

nova-inline-text-field

This Laravel Nova package adds an inline text field to Nova's arsenal of fields.
Vue
17
star
22

nova-resizable

A simple tool to allow resizing of nova resource table.
JavaScript
16
star
23

nova-locale-manager

An extremely simple Laravel Nova tool for managing locales.
PHP
15
star
24

nova-lang

This Laravel Nova package allows you to sort Nova resource's index view and assign locales to resources
Vue
14
star
25

create-frontend

JavaScript
11
star
26

nova-redirects

Redirect manager for Laravel Nova
PHP
11
star
27

laravel-generate-storage-structure

This package generates the Laravel storage folder structure. Useful when mounting an empty directory to replace `storage/` in production or staging environments.
PHP
9
star
28

nova-grid

Allow placing fields in a grid formation using ->size() helpers.
Vue
8
star
29

nova-charcounted-fields

Mirror of elevate-digital/nova-charcounted-fields.
Vue
7
star
30

laravel-create-frontend

PHP
7
star
31

core-js

A collection of JS functionalities that we commonly need to use.
JavaScript
6
star
32

core-scss

This is a SCSS partial that provides some utility mixins and default styles that fit our workflow.
CSS
5
star
33

nova-trumbowyg-field

This Laravel Nova package adds a Trumbowyg field to Nova's arsenal of fields.
PHP
5
star
34

laravel-thumbor

PHP
5
star
35

stylelint-config-rules

This is a set of rules for StyleLint.
JavaScript
4
star
36

react-countdown

JavaScript
4
star
37

softreport-linux-client

Repository to retrieve version data from server and send it to SoftReport backend
JavaScript
4
star
38

eslint-config-rules

This is a set of rules for ESLint.
JavaScript
4
star
39

nova-tooltip-field

This Laravel Nova package adds a tooltip field to Nova's arsenal of fields.
Vue
3
star
40

laravel-elastic-logger

Package to listen to Laravel MessageLogged event and queue the log data to be sent to Elastic logs over API.
PHP
3
star
41

nova-currency-vat-field

A Laravel Nova Currency field extension with VAT toggle.
Vue
3
star
42

laravel-healthz

Health check route for Laravel application.
PHP
2
star
43

laravel-console-over-http

PHP
2
star
44

nova-openai

PHP
2
star
45

using-models-in-laravel-migrations

Article about how to use models in Laravel migrations
PHP
1
star
46

nova-account-settings

PHP
1
star
47

laravel-google-cloud-queues

Manage Google Cloud queues from Laravel app.
PHP
1
star
48

nova-release-tracking

Github Action to track nova releases
JavaScript
1
star
49

nova-translations-loader-php

A Laravel Nova package that simplifies the loading of translations inside other packages.
PHP
1
star