定制 jeanlrnt/laravel-cancellable 二次开发

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

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

jeanlrnt/laravel-cancellable

最新稳定版本:1.3

Composer 安装命令:

composer require jeanlrnt/laravel-cancellable

包简介

An cancellable trait package for Laravel Eloquent models

README 文档

README

Build Status Total Downloads Last stable version Code Coverage License

A simple package for making Laravel Eloquent models 'cancellable'. This package allows for the easy cancelling of models by creating various macros to be used within method chaining.

Installation

This package requires PHP 7.3 or higher and Laravel 6.0 or higher.

You can install the package via composer:

composer require jeanlrnt/laravel-cancellable

Usage

Migrations

The Cancellable trait works similarly to Laravel's SoftDeletes trait. This package also ships with a helpful macro for Laravel's \Illuminate\Database\Schema\Blueprint. To get started, simply add the cancelledAt macro to your migration, like so:

Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('user_id');
    $table->string('title');
    $table->timestamps();
    $table->cancelledAt(); // Macro
});

Eloquent

You can now, safely, include the Cancellable trait in your Eloquent model:

namespace App\Models;

use \Illuminate\Database\Eloquent\Model;
use \LaravelCancellable\Cancellable;

class Post extends Model {

    use Cancellable;
    ...
}

Extensions

The extensions shipped with this trait include; cancel, unCancel, withCancelled, withoutCancelled, onlyCancelled and can be used accordingly:

$user = User::first();
$user->cancel();
$user->unCancel();

$usersWithCanceled = User::query()->withCanceled();
$onlyCanceledUsers = User::query()->onlyCanceled();

By default, the global scope of this trait uses the withoutCanceled extension when the trait is added to a model.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email contact@jeanlaurent.fr instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 24
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固