image = $form_model->getItem('image'); $model->entity = $form_model->getItem('entity'); $model->entity_id = $form_model->getItem('entity_id'); return false; } public function update(FormModel $form_model, Photo $photo): false|Photo { $photo->image = $form_model->getItem('image'); $photo->entity = $form_model->getItem('entity'); $photo->entity_id = $form_model->getItem('entity_id'); if ($photo->save()){ return $photo; } return false; } public static function getByEntity(string $entity, int $entity_id): string { $photo = Photo::where("entity", $entity)->where("entity_id", $entity_id)->first(); return $photo->image ?? ""; } }