承接 stepanenko3/nova-settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stepanenko3/nova-settings

最新稳定版本:v1.1.2

Composer 安装命令:

composer require stepanenko3/nova-settings

包简介

This Laravel Nova settings tool based on env, using nativ nova fields and resources

README 文档

README

Latest Version on Packagist Total Downloads License

screenshot of tool

Description

This Laravel Nova settings tool based on env, using nativ nova fields and resources

Features

  • Using native Nova resources
  • Fully responsive
  • Dark mode support
  • Support all packages. Like nova-tabs, activity-log, etc.
  • Different settings depending on the current Env
  • Separation of settings into different classes
  • Customizable model and resource

Requirements

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

Installation

# Install the package composer require stepanenko3/nova-settings

Publish the config file:

php artisan vendor:publish --provider="Stepanenko3\NovaSettings\ToolServiceProvider" --tag="config"

Publish the migration file:

php artisan vendor:publish --provider="Stepanenko3\NovaSettings\ToolServiceProvider" --tag="migrations"

And run php artisan migrate

Next up, you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvder.php // ... public function tools() { return [ // ... new \Stepanenko3\NovaSettings\NovaSettingsTool(), ]; }

Create your own configuration classes in app/Nova/Settings

// in app/Nova/Settings/Demo.php <?php namespace App\Nova\Settings; use Laravel\Nova\Fields\Boolean; use Stepanenko3\NovaSettings\Types\AbstractType; class Demo extends AbstractType { public function fields(): array { return [ Boolean::make('Param 1', 'param_1'), Boolean::make('Param 2', 'param_2'), Boolean::make('Param 3', 'param_3'), ]; } }

With Tabs

If you want to use eminiarts/nova-tabs

composer require eminiarts/nova-tabs

// in app/Nova/Settings/Demo.php <?php namespace App\Nova\Settings; use Eminiarts\Tabs\Tab; use Eminiarts\Tabs\Tabs; use Laravel\Nova\Fields\Boolean; use Stepanenko3\NovaSettings\Types\AbstractType; class Demo extends AbstractType { public function fields(): array { return [ Boolean::make('Param 1', 'param_1'), Boolean::make('Param 2', 'param_2'), Boolean::make('Param 3', 'param_3'), new Tabs('Tabs 1', [ new Tab('Tab 1', [ Boolean::make('Param 1', 'param_1'), Boolean::make('Param 2', 'param_2'), Boolean::make('Param 3', 'param_3'), ]), new Tab('Tab 2', [ Boolean::make('Param 1', 'param_1'), Boolean::make('Param 2', 'param_2'), Boolean::make('Param 3', 'param_3'), ]), new Tab('Tab 3', [ Boolean::make('Param 1', 'param_1'), Boolean::make('Param 2', 'param_2'), Boolean::make('Param 3', 'param_3'), ]), ]), ]; } }

Delcare your settings class in config/nova-settings.php

<?php return [ 'model' => \Stepanenko3\NovaSettings\Models\Settings::class, 'resource' => \Stepanenko3\NovaSettings\Resources\Settings::class, 'types' => [ \App\Nova\Settings\Demo::class, // Add this line ], ];

Usage

Click on the "Settings" menu item in your Nova app to see the tool.

Use helper function for access the settings

// settings(string|null $section, string|null $key = null, string|null $default = null, string|null $env = null) settings('demo', 'key', 'defaultValue', config('app.env'))

Get cart_link value from General settings in current Env

settings('general', 'cart_link')

Get all General settings

settings('general')

Get cart_link value from General settings in specific Env with default value

settings( section: 'general', key: 'cart_link', default: true, env: 'production' ); // OR settings('general', 'cart_link', true, 'production');

Configuration

All the configuration is managed from a single configuration file located in config/nova-settings.php

Extends default model

Create your own model that will extends \Stepanenko3\NovaSettings\Models\Settings

// in app/Models/Settings.php <?php namespace App\Models; use Spatie\Activitylog\LogOptions; use Spatie\Activitylog\Traits\LogsActivity; class Settings extends \Stepanenko3\NovaSettings\Models\Settings { use LogsActivity; public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logFillable() ->logOnlyDirty(); } }

Declare your model 'model' => \App\Models\Settings::class, in config/nova-settings.php

Extends default Nova resource

Create your own resource that will extends \Stepanenko3\NovaSettings\Resources\Settings

// in app/Nova/Settings.php <?php namespace App\Nova; use Illuminate\Http\Request; use Laravel\Nova\Fields\HasMany; class Settings extends \Stepanenko3\NovaSettings\Resources\Settings { public function fields(Request $request) { return array_merge(parent::fields($request), [ HasMany::make('Activities', 'activities', 'App\Nova\ActivityLog'), ]); } }

Declare your resource 'resource' => \App\Nova\Settings::class, in config/nova-settings.php

Don't forget to create App\Nova\ActivityLog

Using dependsOn with out package

Use the settings-> prefix in the attribute parameter of the dependsOn method. It is also necessary to get data from FormData with settings-> prefix

Select::make('Purchase Type', 'type') ->options([ 'personal' => 'Personal', 'gift' => 'Gift', ]), Text::make('Recipient') ->readonly() ->dependsOn( ['settings->type'], function (Text $field, NovaRequest $request, FormData $formData) { if ($formData->{'settings->type'} === 'gift') { $field->readonly(false)->rules(['required', 'email']); } } ),

Screenshots

screenshot of tool

Credits

Contributing

Thank you for considering contributing to this package! Please create a pull request with your contributions with detailed explanation of the changes you are proposing.

License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 18.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固