json-api-server/docs/delete.md

677 B

Deleting Resources

You can allow resources to be deleted using the deletable and notDeletable methods on the schema builder.

Optionally pass a closure that returns a boolean value.

$type->deletable();

$type->deletable(function (Context $context) {
    return $context->getRequest()->getAttribute('user')->isAdmin();
});

Events

deleting

Run before the model is deleted.

$type->deleting(function (&$model, Context $context) {
    // do something
});

deleted

Run after the model is deleted.

$type->deleted(function (&$model, Context $context) {
    // do something
});