rest api expand
This commit is contained in:
@ -14,30 +14,9 @@ class PostRestController extends RestController
|
||||
$this->model = new Post();
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionView($id): void
|
||||
protected function expand(): array
|
||||
{
|
||||
$model = $this->model->where("id", $id)->first();
|
||||
$model->load("user");
|
||||
$res = [];
|
||||
if ($model){
|
||||
$res = $model->toArray();
|
||||
}
|
||||
|
||||
$this->renderApi($res);
|
||||
return ["user"];
|
||||
}
|
||||
|
||||
#[NoReturn] public function actionDelete($id): void
|
||||
{
|
||||
$model = $this->model->where("id", $id)->first();
|
||||
$model->load("user");
|
||||
$res = [];
|
||||
if ($model){
|
||||
$res = $model->toArray();
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
|
||||
$this->renderApi($res);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user