添加选项数据库功能

dev-master 2020-07-30 21:06 UTC

This package is auto-updated.

Last update: 2024-09-05 04:40:30 UTC


README

这是一个用于从数据库中保存和检索选项的 Laravel 扩展包。您可以轻松高效地将值保存到数据库中并从中检索它们。

安装

composer require robotkudos/rkdb

将服务提供者添加到 config/app.php

<?php

'providers' => [
    // ...

    RobotKudos\RKDB\RKDBServiceProvider::class
];

就是这样!

用法

使用 RKDB 非常简单。

使用 artisan 运行迁移: php artisan migrate,现在您可以轻松地保存和检索数据库中的选项;示例

<?php

use RobotKudos/RKDB/Options;

// save option to db
// $options->set(string $key, string $value, string $group_key, optional string $group_title, optional string $type);
$options = new Options();
// if it already exists on the DB, it will be updated.
$options->set('website_title', 'My Cool Website', 'homepage_options', 'Website Title', 'Home Page Options', 'text');

// then get the option
// $options->get(string $key, optional string $default);
$options->get('website_title', 'Default Website Title');