rest api expand

This commit is contained in:
apuc committed 2024-10-07 11:31:16 +03:00
1 parent 160c381abc
commit 5fe6bd9629
3 files changed
+13 -25

No files matched your search

+10
View File
@@ -11,6 +11,12 @@ class RestController
protected Model $model;
protected function expand(): array
{
return [];
}
#[NoReturn] public function actionIndex(): void
{
$request = new Request();
@@ -29,7 +35,11 @@ class RestController
#[NoReturn] public function actionView($id): void
{
$expand = $this->expand();
$model = $this->model->where("id", $id)->first();
if ($expand){
$model->load($expand);
}
$res = [];
if ($model){
$res = $model->toArray();