Delete
Introduction
Laravel Rest Api exposes endpoints to manage entries' lifecycles. Here is how to consume them.
Usage
Call the specified endpoint and add in the body the specified entries you want to destroy:
// (DELETE) my-api.com/api/users
{
"resources": [5,6]
}
Response
As a response you'll receive the deleted records.
{
"data": [
{
"id": 1,
"name": "Evan Sauer"
}
],
"meta": {
"gates": {
"authorized_to_create": true
}
}
}
Soft Deletes
If you deal with softDeletes you should specify it first when registering the controller:
api.php
use \Lomkit\Rest\Facades\Rest;
Rest::resource('users', \App\Rest\Resources\UsersController::class)->withSoftDeletes()
Restore
Call the specified endpoint and add in the body the specified entries you want to restore:
// (POST) my-api.com/api/users/restore
{
"resources": [5,6]
}
Force Delete
Call the specified endpoint and add in the body the specified entries you want to force delete:
// (DELETE) my-api.com/api/users/force
{
"resources": [5,6]
}
Table of Contents