Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17b0cad

Browse files
committed
Make Builder::get method respect generic
1 parent 6b4f671 commit 17b0cad

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

stubs/database/eloquent/builder.stub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ class Builder
1212
* @return TModel|null
1313
*/
1414
public function first($columns = ['*']);
15+
16+
/**
17+
* @param string[]|string $columns
18+
* @return \Illuminate\Database\Eloquent\Collection<int, TModel>
19+
*/
20+
public function get($columns = ['*']);
1521
}

tests/Types/data/database/eloquent/builder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/** @var \Illuminate\Database\Eloquent\Builder<\Tests\Types\Fakes\User> $builder */
66

77
assertType('Tests\Types\Fakes\User|null', $builder->first());
8+
assertType('Illuminate\Database\Eloquent\Collection<int, Tests\Types\Fakes\User>', $builder->get());

tests/Types/data/database/eloquent/model.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ public function test(): void
1212

1313
assertType('Illuminate\Database\Eloquent\Builder<static(User)>', $this->newEloquentBuilder($baseBuilder));
1414
assertType('static(User)|null', $this->newEloquentBuilder($baseBuilder)->first());
15+
assertType('Illuminate\Database\Eloquent\Collection<int, static(User)>', $this->newEloquentBuilder($baseBuilder)->get());
1516

1617
assertType('Illuminate\Database\Eloquent\Builder<static(User)>', self::query());
1718
assertType('static(User)|null', self::query()->first());
19+
assertType('Illuminate\Database\Eloquent\Collection<int, static(User)>', self::query()->get());
1820
}
1921
}

0 commit comments

Comments
 (0)