で定義されているメソッドを使用しますgetParentFighterToUpdate()
の定義は両方のサブクラスにのみ存在しますが、Fight
クラスには存在しません。したがって、私は得る:は、私はメソッドを持っている唯一のサブクラス
BadMethodCallException in Builder.php line 2443:
Call to undefined method
Illuminate\Database\Query\Builder::getParentFighterToUpdate()
どうすればいいですか?
EDIT:
DirectEliminationFightクラス::ここでは、両方のgetParentFighterToUpdate方法です
public function getParentFighterToUpdate()
{
$childrenGroup = $this->group->parent->children;
foreach ($childrenGroup as $key => $children) {
$childFight = $children->fights->get(0);
if ($childFight->id == $this->id) {
if ($key % 2 == 0) {
return "c1";
}
if ($key % 2 == 1) {
return "c2";
}
}
}
return null;
}
PreliminaryFightクラス
public function getParentFighterToUpdate()
{
$childrenGroup = $this->group->parent->children;
foreach ($childrenGroup as $key => $children) {
$childFights = $children->fights;
dd($childFights);
// Still writing it
}
return null;
}
EDIT 2:
/**
* Update fighter if it is possible
* @param $fightsByRound
*/
protected function updateParentFight(Collection $fightsByRound)
{
foreach ($fightsByRound as $fight) {
$parentGroup = $fight->group->parent;
if ($parentGroup == null) break;
$parentFight = $parentGroup->fights->get(0);
$this->chooseAndUpdateParentFight($fight, $parentFight);
}
}
'getParentFighterToUpdate()'メソッドを両方表示できますか? –
私は自分の質問を編集しました –
'Fight'モデルで' getParentFighterToUpdate 'を定義し、' if(class_basename(static :: class)== 'PreliminaryFight') 'のように、アップ。それはあなたが 'chooseAndUpdateParentFight'にサブクラスの1つを渡していない理由があると言われていますか? –