public function customAnswer($customquestion_id, $account_id, $rate) { $answer = Model::Customanswer()->firstOrcreate(['customquestion_id' => $customquestion_id, 'account_id' => $account_id]); $answer->rate = $rate; $answer->save(); return $answer->id; }