@@ -163,7 +163,7 @@ protected function isMorphRelation($relation)
163163 /**
164164 * Check if a relation is a HasManyDeep relationship.
165165 *
166- * @param \Illuminate\Database\Eloquent\Relations\Relation $model
166+ * @param \Illuminate\Database\Eloquent\Relations\Relation<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model, mixed> $model
167167 */
168168 protected function isHasManyDeep ($ model ): bool
169169 {
@@ -175,7 +175,7 @@ protected function isHasManyDeep($model): bool
175175 * Get the foreign key name for a HasManyDeep relationship.
176176 * This is the foreign key on the final related table that points to the intermediate table.
177177 *
178- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
178+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
179179 */
180180 protected function getHasManyDeepForeignKey ($ model ): string
181181 {
@@ -203,7 +203,7 @@ protected function getHasManyDeepForeignKey($model): string
203203 * Get the local key name for a HasManyDeep relationship.
204204 * This is the local key on the intermediate table (or parent if no intermediate).
205205 *
206- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
206+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
207207 */
208208 protected function getHasManyDeepLocalKey ($ model ): string
209209 {
@@ -223,7 +223,7 @@ protected function getHasManyDeepLocalKey($model): string
223223 $ through = $ this ->getThroughModels ($ model );
224224 $ fallbackKey = $ model ->getParent ()->getKeyName ();
225225 if ($ intermediateTable && ! empty ($ through )) {
226- $ firstThrough = is_string ($ through [0 ]) ? $ through [0 ] : $ through [0 ]::class ;
226+ $ firstThrough = is_string ($ through [0 ]) ? $ through [0 ] : get_class ( $ through [0 ]) ;
227227 if (class_exists ($ firstThrough )) {
228228 $ fallbackKey = app ($ firstThrough )->getKeyName ();
229229 }
@@ -235,7 +235,7 @@ protected function getHasManyDeepLocalKey($model): string
235235 /**
236236 * Get the intermediate table name for a HasManyDeep relationship.
237237 *
238- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
238+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
239239 * @param string $lastAlias
240240 */
241241 protected function getHasManyDeepIntermediateTable ($ model , $ lastAlias ): ?string
@@ -245,7 +245,7 @@ protected function getHasManyDeepIntermediateTable($model, $lastAlias): ?string
245245 $ through = $ this ->getThroughModels ($ model );
246246 if (! empty ($ through )) {
247247 // Get the first intermediate model
248- $ firstThrough = is_string ($ through [0 ]) ? $ through [0 ] : $ through [0 ]::class ;
248+ $ firstThrough = is_string ($ through [0 ]) ? $ through [0 ] : get_class ( $ through [0 ]) ;
249249 if (class_exists ($ firstThrough )) {
250250 $ throughModel = app ($ firstThrough );
251251
@@ -259,7 +259,7 @@ protected function getHasManyDeepIntermediateTable($model, $lastAlias): ?string
259259 /**
260260 * Get the foreign key for joining to the intermediate table.
261261 *
262- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
262+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
263263 */
264264 protected function getHasManyDeepIntermediateForeignKey ($ model ): string
265265 {
@@ -282,7 +282,7 @@ protected function getHasManyDeepIntermediateForeignKey($model): string
282282 /**
283283 * Get the local key for joining from the parent to the intermediate table.
284284 *
285- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
285+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
286286 */
287287 protected function getHasManyDeepIntermediateLocalKey ($ model ): string
288288 {
@@ -402,6 +402,7 @@ protected function joinEagerLoadedColumn($relation, $relationColumn)
402402 case $ this ->isHasManyDeep ($ model ):
403403 // HasManyDeep relationships can traverse multiple intermediate models
404404 // We need to join through all intermediate models to reach the final related table
405+ /** @var \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model */
405406 $ related = $ model ->getRelated ();
406407
407408 // Get the qualified parent key to determine the first intermediate model
@@ -493,7 +494,7 @@ protected function performJoin($table, $foreign, $other, $type = 'left'): void
493494 /**
494495 * Extract the array of foreign keys from a HasManyDeep relationship using reflection.
495496 *
496- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
497+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
497498 */
498499 private function getForeignKeys ($ model ): array
499500 {
@@ -518,7 +519,7 @@ private function getForeignKeys($model): array
518519 /**
519520 * Extract the array of local keys from a HasManyDeep relationship using reflection.
520521 *
521- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
522+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
522523 */
523524 private function getLocalKeys ($ model ): array
524525 {
@@ -543,7 +544,7 @@ private function getLocalKeys($model): array
543544 /**
544545 * Extract the array of through models from a HasManyDeep relationship using reflection.
545546 *
546- * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep $model
547+ * @param \Staudenmeir\EloquentHasManyDeep\HasManyDeep<\Illuminate\Database\Eloquent\Model, \Illuminate\Database\Eloquent\Model> $model
547548 */
548549 private function getThroughModels ($ model ): array
549550 {
0 commit comments