PHP code example of diogo2550 / database-system-setting

1. Go to this page and download the library: Download diogo2550/database-system-setting 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/ */

    

diogo2550 / database-system-setting example snippets



// config/settings-schema.php

return [
    'schema' => [
        'trending_items_limit' => [
            'default' => 7,
            'description' => 'Number of items displayed in the "Trending" section on the Home page',
            'schema' => [
                'type' => 'integer',
                '=> true,
            ],
        ],
        'contact_email' => [
            'default' => '[email protected]',
            'description' => 'Official email for receiving feedback',
            'schema' => [
                'type' => 'email',
                '

// In a Controller to set pagination
$limit = config('settings.trending_items_limit', 7);
$articles = Article::trending()->take($limit)->get();

// In a Blade View to conditionally render blocks
@if(config('settings.enable_ezoic_ads'))
    <div id="ezoic-pub-ad-placeholder-101"></div>
@endif

'__internal__' => [
    'cache' => [
        'enabled' => env('SETTINGS_CACHE_ENABLED', true), // Easy control via .env
        'key' => 'dsystem_setting',
        'ttl' => 60 * 60 * 24, // 24 hours in seconds
    ],
    'table_name' => 'system_settings',
],
bash
php artisan vendor:publish --tag=database-system-setting
bash
php artisan migrate
bash
php artisan database-system-setting:sync