model = new User(); } #[NoReturn] public function actionAuth(): void { $request = new Request(); $data = $request->post(); $model = $this->model->where(['username', $data['username']])->first(); $access_token = 123124312313; $access_token_expires_at = time() + 3600; $model->{'access_token'} = $access_token; $model->{'access_token_expires_at'} = $access_token_expires_at; foreach ($model->getFillable() as $item){ $model->{$item} = $data[$item] ?? null; } $model->save(); $this->renderApi($this->model->toArray()); } }