lanehub/laravel-bit-status
Composer 安装命令:
composer require lanehub/laravel-bit-status
包简介
laravel orm bit status trait
README 文档
README
laravel orm bit status trait.
Installing
$ composer require lanehub/laravel-bit-status -vvv
Usage
Migrate database
$table->unsignedTinyInteger('status'); // 1 byte -> maximum of 8 different values
$table->unsigneInteger('status'); // 4 byte -> maximum of 32 different values
$table->unsignedBigInteger('status'); // 8 byte -> maximum of 64 different values
Add trait
use Illuminate\Database\Eloquent\Model;
use Lanehub\LaravelBitStatus\BitStatusTrait;
class TestModel extends Model
{
const STATUS_INFO_COMPLETED = 1; // 0001
const STATUS_AVATAR_COMPLETED = 2; // 0010
const STATUS_DESC_COMPLETED = 3; // 0100
const STATUS_FOO_COMPLETED = 4; // 1000
use BitStatusTrait;
}
$test = new TestModel;
$test->setBitStatus('status', TestModel::STATUS_AVATAR_COMPLETED); // default set true
$test->setBitStatus('status', TestModel::STATUS_AVATAR_COMPLETED, true); // same as above
$test->getBitStatus('success', TestModel::STATUS_AVATAR_COMPLETED); // true
$test->setBitStatus('status', TestModel::STATUS_AVATAR_COMPLETED, false); // set false
$test->getBitStatus('status', TestModel::STATUS_AVATAR_COMPLETED); // false
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT
统计信息
- 总下载量: 171
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-22