定制 pristavu/laravel-cancellation 二次开发

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

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

pristavu/laravel-cancellation

最新稳定版本:v4.0.0

Composer 安装命令:

composer require pristavu/laravel-cancellation

包简介

A laravel cancellation package

README 文档

README

Latest Version on Packagist Tests StyleCI Quality Score Total Downloads

The signifly/laravel-cancellation package allows you to easily handle cancellation of your models. It is inspired by the SoftDeletes implementation in Laravel.

All you have to do to get started is:

// 1. Add cancelled_at column to your table by using our macro cancellable
Schema::create('orders', function (Blueprint $table) {
    // ...
    $table->cancellable();
    // ...
});

// 2. Add the Cancellable trait to your model
class Order extends Model
{
    use Cancellable;
}

Here's a little demo of how you can use it after adding the trait:

$order = Order::find(1);
$order->cancel();

You can query cancelled entities:

$orders = Order::onlyCancelled()->get(); // returns all the cancelled entities
$orders = Order::withCancelled()->get(); // includes cancelled entities
$orders = Order::withoutCancelled()->get(); // excludes cancelled entities

Other useful methods:

$order->isCancelled(); // returns true or false
$order->keep(); // keep a cancelled order

Order::whereKey([1, 2, 3])->keep(); // keeps orders with ids: 1, 2, 3

Installation

You can install the package via composer:

$ composer require signifly/laravel-cancellation

The package will automatically register itself.

You can publish the config with:

$ php artisan vendor:publish --provider="Signifly\Cancellation\CancellationServiceProvider" --tag="config"

Note: If you set the exclude variable to true in your config, your query results will not include cancelled results by default (just like SoftDeletes).

This is the contents of the published config file:

return [
    /**
     * Exclude the cancellations from the model's queries.
     * Will apply to all, find, etc.
     */
    'exclude' => false,
];

Testing

$ composer test

Security

If you discover any security issues, please email dev@signifly.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固