path = $form_model->getItem('path'); $model->status = $form_model->getItem('status'); $model->title = $form_model->getItem('title'); // $model->slug = Slug::createSlug($form_model->getItem('title'), Card::class); // Генерация уникального slug if ($model->save()) { return $model; } return false; } public function update(FormModel $form_model, CardTemplate $cardTemplate): false|CardTemplate { // Пример обновления: $cardTemplate->title = $form_model->getItem('title'); $cardTemplate->path = $form_model->getItem('path') ?? $cardTemplate->path; $cardTemplate->status = $form_model->getItem('status'); if ($cardTemplate->save()) { return $cardTemplate; } return false; } public static function getTemplatesList(): array { $arr = []; foreach (CardTemplate::all()->toArray() as $cardTemplate){ $arr[$cardTemplate['id']] = $cardTemplate['title']; } if (!empty($arr)) { return $arr; } return []; } }