Updates the package so that it now supports soft deleting. To do this, there is now a SoftDeleteRepository and SoftDeleteHydrator, that extend the existing classes and override the methods required to handle soft delete models.
If a model is soft-deletable, but the schema is not modified, then the model will be soft-deleted on a DELETE request, and will then not appear in the API.
If the soft delete functionality should be exposed to the client, then the LaravelJsonApi\Eloquent\SoftDeletes trait should be added to the schema, and an instance of LaravelJsonApi\Eloquent\Fields\SoftDelete should be added to the schema's fields. Once this is done, a client can soft-delete or restore a resource using a PATCH request, with the standard Eloquent delete/restore events fired as a result. A DELETE request will force delete the resource.
The PR also adds three filters. OnlyTrashed and WithTrashed use the onlyTrashed() and withTrashed() scopes that Eloquent adds for soft deletable models. The WhereTrashed effectively allows resources to be filtered by whether they are trashed or not (which is a slightly different behaviour to the Eloquent withTrashed() scope).
Updates the package so that it now supports soft deleting. To do this, there is now a
SoftDeleteRepository
andSoftDeleteHydrator
, that extend the existing classes and override the methods required to handle soft delete models.If a model is soft-deletable, but the schema is not modified, then the model will be soft-deleted on a
DELETE
request, and will then not appear in the API.If the soft delete functionality should be exposed to the client, then the
LaravelJsonApi\Eloquent\SoftDeletes
trait should be added to the schema, and an instance ofLaravelJsonApi\Eloquent\Fields\SoftDelete
should be added to the schema's fields. Once this is done, a client can soft-delete or restore a resource using aPATCH
request, with the standard Eloquent delete/restore events fired as a result. ADELETE
request will force delete the resource.The PR also adds three filters.
OnlyTrashed
andWithTrashed
use theonlyTrashed()
andwithTrashed()
scopes that Eloquent adds for soft deletable models. TheWhereTrashed
effectively allows resources to be filtered by whether they are trashed or not (which is a slightly different behaviour to the EloquentwithTrashed()
scope).Implements https://github.com/laravel-json-api/laravel/issues/43