PHP code example of devloops / nova-system-settings

1. Go to this page and download the library: Download devloops/nova-system-settings 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/ */

    

devloops / nova-system-settings example snippets




namespace App\Nova\Settings\General;

use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Devloops\NovaSystemSettings\Contracts\SystemSettings;


class SiteSettings extends SystemSettings
{

    public ?string $title;

    public ?string $slogan;

    public ?string $email;

    public ?string $phoneNumber;

    public ?string $address;

    public static function group(): string
    {
        return 'general';
    }

    public static function title(): string
    {
        return __('Site Settings');
    }

    public static function icon(): string
    {
        return 'cog';
    }

    public static function name(): string
    {
        return 'site_settings';
    }

    public static function fields(): array
    {
        return [
            Text::make(__('Site Title'), 'title'),
            Text::make(__('Site Slogan'), 'slogan'),
            Text::make(__('Site Email'), 'email'),
            Text::make(__('Site Phone Number'), 'phoneNumber'),
            Textarea::make(__('Site Address'), 'address'),
        ];
    }
}



namespace App\Nova\Settings\General;

use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Password;
use Devloops\NovaSystemSettings\Contracts\SystemSettings;

class MailSettings extends SystemSettings
{

    public ?string $mailer;

    public ?string $host;

    public ?int $port;

    public ?string $username;

    public ?string $password;

    public ?string $encryption;

    public static function group(): string
    {
        return 'general';
    }

    public static function title(): string
    {
        return __('Mail Settings');
    }

    public static function icon(): string
    {
        return 'mail';
    }

    public static function name(): string
    {
        return 'mail_settings';
    }

    public static function fields(): array
    {
        return [
            Select::make(__('Mailer'), 'mail')
                  ->options([
                      'smtp'     => __('SMTP'),
                      'sendmail' => __('Sendmail'),
                      'mailgun'  => __('Mailgun'),
                  ]),
            Text::make(__('Host'), 'host'),
            Number::make(__('Port'), 'port'),
            Text::make(__('Username'), 'username'),
            Password::make(__('Password'), 'password'),
            Select::make(__('Encryption'), 'encryption')
                  ->options([
                      null  => __('None'),
                      'tls' => __('TLS'),
                      'ssl' => __('SSL'),
                  ]),
        ];
    }
}




namespace App\Nova\Settings\Store;

use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Boolean;
use Devloops\NovaSystemSettings\Contracts\SystemSettings;

class OrderSettings extends SystemSettings
{
    public ?float $minOrder;

    public ?bool $allowGuestCheckout;

    public ?bool $allowFreeShipping;

    public static function group(): string
    {
        return 'store';
    }

    public static function title(): string
    {
        return __('Order Settings');
    }

    public static function icon(): string
    {
        return 'shopping-cart';
    }

    public static function name(): string
    {
        return 'order_settings';
    }

    public static function fields(): array
    {
        return [
            Number::make(__('Minimum Order'), 'minOrder'),
            Boolean::make(__('Allow Guest Checkout'), 'allowGuestCheckout'),
            Boolean::make(__('Allow Free Shipping'), 'allowFreeShipping'),
        ];
    }
}



namespace App\Nova\Settings\Tenant\Store;

use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Boolean;
use Devloops\NovaSystemSettings\Contracts\SystemSettings;

class CustomerSettings extends SystemSettings
{

    public ?string $loginVia;

    public ?bool $'user';
    }

    public static function name(): string
    {
        return 'customer_settings';
    }

    public static function fields(): array
    {
        return [
            Select::make(__('Login Via'))
                  ->options([
                      'email'        => __('Email'),
                      'phone_number' => __('Phone Number'),
                  ]),
            Boolean::make(__('Requires Email Verification'), '


    /**
     * Get system settings group.
     *
     * @return string
     */
    abstract public static function group(): string;

    /**
     * Get system settings title.
     *
     * @return string
     */
    abstract public static function title(): string;

    /**
     * Get system settings icon.
     *
     * @return string
     */
    abstract public static function icon(): string;

    /**
     * Get system settings name.
     *
     * @return string
     */
    abstract public static function name(): string;

    /**
     * Return system settings fields.
     *
     * @return array
     */
    abstract public static function fields(): array;


use App\Nova\Settings\General\SiteSettings;
use App\Nova\Settings\General\MailSettings;
use App\Nova\Settings\Store\OrderSettings;
use App\Nova\Settings\Store\CustomerSettings;

    public function tools(): array
    {
        return [
            NovaSystemSettings::make([
                //General
                SiteSettings::make(),
                MailSettings::make(),

                //Store
                OrderSettings::make(),
                CustomerSettings::make()
            ]),
        ];
    }



return [
    'groups' => [        
        'general'          => 'General',
        'store'            => 'Store',
    ],
];



namespace App\Http\Controllers\Api\V1;

use App\Nova\Settings\Store\CustomerSettings;
use App\Http\Requests\Api\V1\Auth\SendOtpRequest;

class AuthController extends ApiController
{

    public function __construct(
        public CustomerSettings $customerSettings
    ) {
    }

    public function sendOtp(SendOtpRequest $request)
    {
        dd($this->customerSettings->loginVia);
    }
}