Skip to content

pactode/laravel-cancellation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cancel models inside your Laravel app

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 orders

Documentation

Until further documentation is provided, please have a look at the tests.

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 [email protected] instead of using the issue tracker.

Credits

License

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

About

Cancel models in your Laravel app.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%