定制 caiosalchesttes/laravel-flag 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

caiosalchesttes/laravel-flag

最新稳定版本:1.0.1

Composer 安装命令:

composer require caiosalchesttes/laravel-flag

包简介

Laravel Flag is a package that allows you to create flags in your database tables.

README 文档

README

This library aims to add an additional column in the tables, which can be used as a "cache" to add and remove flags.

The cache column can be useful for storing temporary information that is used by the application but doesn't need to be permanent. It can be used, for example, to store session information or to mark records for deletion in a batch operation.

The library provides the following methods:

Add Flag to Cache Column of a Specific Record Remove Flag from Cache Column of a Specific Record Query the Flag Value in a Specific Record Thus, you can manage the flags stored in the cache column efficiently and conveniently.

Installation

composer require caiosalchesttes/laravel-flag

We must add in your migrations to generate the column

   public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->flag();
        });
    }

After that you can put in your model what you want to use

<?php

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Caiosalchesttes\LaravelFlag\Flag:

class User extends Authenticatable
{
    use Notifiable, Flag:

Some methods you can use

Add

$user = User::find(1);
$user->addFlag('key', 'value');
$user->save();

Add persist

$user = User::find(1);
$user->addFlagPersist('key', 'value');

Remove flag

$user = User::find(1);
$user->removeFlag('key');
$user->save();

Remove flag persist

$user = User::find(1);
$user->removeFlagPersist('key');

Clear all flags

$user = User::find(1);
$user->clearFlags();
$user->save();

Has flag

$user = User::find(1);
$user->hasFlag('key');

Get flag

$user = User::find(1);
$user->getFlag('key');

Get all flags

$user = User::find(1);
$user->getFlags();

License

MIT License (MIT). Please, read the License File for more informations.

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-01-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固