2017 © Pedro Peláez
 

library laravel-cancellation

A laravel cancellation package.

image

signifly/laravel-cancellation

A laravel cancellation package.

  • Sunday, January 28, 2018
  • by signifly
  • Repository
  • 4 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Cancel models inside your Laravel app

Latest Version on Packagist Tests StyleCI Quality Score Total Downloads, (*1)

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

All you have to do to get started is:, (*3)

// 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:, (*4)

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

You can query cancelled entities:, (*5)

$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:, (*6)

$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:, (*7)

$ composer require signifly/laravel-cancellation

The package will automatically register itself., (*8)

You can publish the config with:, (*9)

$ 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)., (*10)

This is the contents of the published config file:, (*11)

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., (*12)

Credits

License

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

The Versions

28/01 2018

dev-master

9999999-dev https://github.com/signifly/laravel-cancellation

A laravel cancellation package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Morten Poul Jensen

laravel cancellation signifly

28/01 2018

v1.0.0

1.0.0.0 https://github.com/signifly/laravel-cancellation

A laravel cancellation package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Morten Poul Jensen

laravel cancellation signifly