承接 damodar-bhattarai/settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

damodar-bhattarai/settings

最新稳定版本:1.1.3

Composer 安装命令:

composer require damodar-bhattarai/settings

包简介

Package to store and get general website settings on the fly.

README 文档

README

Store general settings like website name, logo url, contacts in the database easily. Everything is cached, so no extra query is done. You can also get fresh values from the database directly if you need.

Installation

Install the package via composer

composer require damodar-bhattarai/settings

Publish the migrations using the following command

php artisan vendor:publish --provider="DamodarBhattarai\Settings\SettingsServiceProvider"

Migrate the database

php artisan migrate

I have also added seeder for some general settings a website needs. Seed the database using command:

php artisan db:seed --class=SettingsSeeder

Usage/Examples

To store settings on database

settings()->set('key','value'); 

You can also set multiple settings at once

settings()->set([
        'key1'=>'value1',
        'key2'=>'value2',
        'key3'=>'value3'
    ]);

You can retrieve the settings from cache using any command below

settings('key');

settings()->get('key');

You can provide default value to key if that key doesn't exist

settings('key','default');  //returns default
settings()->get('key','default');  //returns default

Want the settings directly from database? You can do it,

settings('key','default',true);
settings()->get('key','default',true);

Getting all the settings stored on database

settings()->getAll();

Lets see some examples:

set "site_name" as "StillAlive"

settings()->set('site_name','StillAlive');

get "site_name" value

settings('site_name'); //outputs StillAlive

set multiple settings

settings()->set([
    'site_name'=>'StillAlive',
    'email'=>'info@bdamodar.com.np'
    'footer_text'=>'Copyright ©',
]);

You can use the settings on blade as

{{ settings('site_name') }}
{{ settings('site_name','default value' )}}

Or, if you have html stored on settings

{!! settings('footer_text') !!}
{!! settings('footer_text',Copyright Date('Y')) !!}

New on v1.0.1 ( short_text helper)

short_text eliminates all the html entities including
so you get clean text from the html provided.

short_text($text, $length = 30, $read_more = false, $link = false, $style = '')

where, $text is html (like from rich text editors)

$length is character limit

$read_more is boolean which helps to show or hide read more link

$link is the link to the above read_more link

$style can be used to add styles and classes like ($style='style="color:blue;" class="font-weight-bold"';)

##example

{{ short_text($post->description,100,true,route('post.show',$post->id),'class="text-red-500"') }}

Finally, If you have changed something directly on database, Don't forget to clear the cache.

php artisan cache:clear 

License

MIT

Feedback

If you have any feedback, please reach out at damodar.bhattarai.1999@gmail.com or submit a pull request here.

Authors

Badges

MIT License

统计信息

  • 总下载量: 2.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 31
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固