parentModel->where('id', $value)->first()->{$this->relationName}; if (!is_null($this->idToIgnore)) { $children = $children->where('id', '!==', $this->idToIgnore); } if ($children->count() >= $this->max) { $parentName = str($this->parentModel->getTable())->singular(); $childrenName = str($this->parentModel->{$this->relationName}()->getModel()->getTable())->singular(); $fail(trans('crud.messages.rule_max_reached', [ 'parent' => str(trans_choice('models.classes.' . $parentName, 1))->title(), 'max' => $this->max, 'children' => str(trans_choice('models.classes.' . $childrenName, 1))->title()->plural() ])); } } }