PHP code example of tarfin-labs / laravel-config
1. Go to this page and download the library: Download tarfin-labs/laravel-config 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/ */
tarfin-labs / laravel-config example snippets
LaravelConfig::getNested('foo');
=> Illuminate\Support\Collection {#3048
all: [
TarfinLabs\LaravelConfig\Config\Config {#3097
id: 1,
name: "bar",
type: "boolean",
val: "0",
description: null,
created_at: "2021-05-06 11:35:05",
updated_at: "2021-05-06 11:35:05",
},
TarfinLabs\LaravelConfig\Config\Config {#3099
id: 2,
name: "baz",
type: "boolean",
val: "1",
description: null,
created_at: "2021-05-06 11:03:48",
updated_at: "2021-05-06 11:03:48",
},
],
}
$config = factory(Config::class)->create([
'name' => 'custom-cast-config-name',
'val' => [ConfigDataType::DATE],
'type' => AsEnumCollection::class.':'.ConfigDataType::class,
]);
php artisan vendor:publish --provider="TarfinLabs\LaravelConfig\LaravelConfigServiceProvider" --tag="laravel-config"
php artisan vendor:publish --provider="TarfinLabs\LaravelConfig\LaravelConfigServiceProvider" --tag="laravel-config-factories"
php artisan migrate
php
$factory = new ConfigFactory();
$configItem = $factory->setName('key')
->setType(ConfigDataType::BOOLEAN)
->setValue('1')
->setTags(['system'])//optional
->setDescription('Lorem ipsum dolor sit amet')
->get();
LaravelConfig::create($configItem);
php
LaravelConfig::get('key');
php
LaravelConfig::set('key', 'value');
php
LaravelConfig::all();
php
LaravelConfig::getByTag('key');
php
LaravelConfig::has('key');
php
$factory = new ConfigFactory($configId);
$configItem = $factory->setName('updated-key')
->setType(ConfigDataType::BOOLEAN)
->setValue('0')
->setTags(['system'])//optional
->setDescription('updated description')
->get();
LaravelConfig::update($configItem);
php
LaravelConfig::delete('key');