PHP code example of norman-huth / nova-single-resource

1. Go to this page and download the library: Download norman-huth/nova-single-resource library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

norman-huth / nova-single-resource example snippets


use NormanHuth\SingleResource\Traits\ResourceTrait;

class Setting extends Resource
{
    use ResourceTrait;  //  parent::__construct($resource);
    }

    protected static function sections(): array
    {
        return [
            'general-settings' => 
            [
                'name'   => __('General Settings'),
                'icon'   => 'eye',
            ],
            'system' => 
            [
                'name'   => __('System'),
                'faIcon' => 'fa-brands fa-laravel fa-fw',
            ],
        ];
    }

    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static string $model = \App\Models\Setting::class;

    public function getGeneralSettingsFields(NovaRequest $request): array
    {
        return [
            Currency::make('Price')->currency('EUR'),
            Text::make(__('Text'), 'text'),
            Boolean::make(__('Boolean'), 'boolean'),
        ];
    }

    public function getSystemFields(NovaRequest $request): array
    {
        return [
            Date::make(__('Date'), 'Date'),
            DateTime::make(__('DateTime'), 'DateTime'),
        ];
    }
}

'general-settings' => // Required: unique slug
[
    'name'   => 'My Settings' // Required: Display section name
    'icon'   => 'eye', // Optional: Heroicon icon https://heroicons.com/
    'faIcon' => 'fa-brands fa-laravel fa-fw', // Optional: FontAwesome Icon (not 

class Setting extends Model
{
    public static string $keyColumn = 'key';
    public static string $valueColumn = 'value';

Text::make(__('SMTP Password'), 'smtp_password')
    ->cast('encrypted'),