mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Start recycle bin API endpoints: list, restore, delete
This commit is contained in:
45
app/Http/Controllers/Api/RecycleBinApiController.php
Normal file
45
app/Http/Controllers/Api/RecycleBinApiController.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace BookStack\Http\Controllers\Api;
|
||||
|
||||
use BookStack\Actions\ActivityType;
|
||||
use BookStack\Entities\Models\Deletion;
|
||||
use BookStack\Entities\Repos\DeletionRepo;
|
||||
use BookStack\Entities\Tools\TrashCan;
|
||||
|
||||
class RecycleBinApiController extends ApiController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->checkPermission('settings-manage');
|
||||
$this->checkPermission('restrictions-manage-all');
|
||||
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return $this->apiListingResponse(Deletion::query(), [
|
||||
'id',
|
||||
'deleted_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deletable_type',
|
||||
'deletable_id'
|
||||
]);
|
||||
}
|
||||
|
||||
public function restore(DeletionRepo $deletionRepo, string $id)
|
||||
{
|
||||
$restoreCount = $deletionRepo->restore((int) $id);
|
||||
return response()->json(['restore_count' => $restoreCount]);
|
||||
}
|
||||
|
||||
public function destroy(DeletionRepo $deletionRepo, string $id)
|
||||
{
|
||||
$deleteCount = $deletionRepo->destroy((int) $id);
|
||||
return response()->json(['delete_count' => $deleteCount]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user