api action delete add, slug generator update
This commit is contained in:
1 parent
d49416a7d2
commit
7ff9d45fe7
4 files changed
+54
-3
No files matched your search
@@ -38,6 +38,20 @@ class RestController
|
||||
$this->renderApi($res);
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionDelete($id): void
|
||||
{
|
||||
$model = $this->model->where("id", $id)->first();
|
||||
$res = [];
|
||||
if ($model){
|
||||
$res = $model->toArray();
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
|
||||
$this->renderApi($res);
|
||||
|
||||
}
|
||||
|
||||
#[NoReturn] protected function renderApi(array $data): void
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
|
||||
Reference in new issue
Block a user