api action delete add, slug generator update
This commit is contained in:
@ -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