anourvalar/config-helper

Helper functions over Laravel config

3.3.0 2024-08-13 16:44 UTC

README

Installation

composer require anourvalar/config-helper

Usage

Config example

// config/example.php

return [
    'user_role' => [
        'admin' => ['title' => 'Administrator', 'super_user' => true],
        'maintainer' => ['title' => 'Maintainer', 'super_user' => true],
        'moderator' => ['title' => 'Moderator'],
        'user' => ['title' => 'User', 'register_via_form' => true],
    ],
];

Get filtered keys of config

\ConfigHelper::keys('example.user_role', ['super_user' => true]); // ['admin', 'maintainer']

Get singleton key

\ConfigHelper::key('example.user_role', ['register_via_form' => true]); // 'user'

HTML select

echo '<select>' . \ConfigHelper::toSelect('example.user_role') . '</select>';