Skip to content

Commit

Permalink
add related selection check
Browse files Browse the repository at this point in the history
  • Loading branch information
cevro committed Aug 16, 2023
1 parent aae7972 commit fd245e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ final public function __construct(array $data, Selection $table)
parent::__construct($data, $table);
}

/**
* @phpstan-return TypedGroupedSelection<Model>
*/
public function related(string $key, ?string $throughColumn = null): TypedGroupedSelection
{
$selection = parent::related($key, $throughColumn);
if ($selection instanceof TypedGroupedSelection) {
return $selection;
}
throw new \InvalidArgumentException();
}

/**
* @return Model|mixed
* @throws MemberAccessException|\ReflectionException
Expand Down

0 comments on commit fd245e8

Please sign in to comment.