PHP code example of signifly / laravel-cancellation
1. Go to this page and download the library: Download signifly/laravel-cancellation library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
signifly / laravel-cancellation example snippets
// 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;
}
$order = Order::find(1);
$order->cancel();
$orders = Order::onlyCancelled()->get(); // returns all the cancelled entities
$orders = Order::withCancelled()->get(); //
$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
return [
/**
* Exclude the cancellations from the model's queries.
* Will apply to all, find, etc.
*/
'exclude' => false,
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.