Skip to content

Commit 830ecc9

Browse files
authored
Fixed select(), implemented pluck(), ids(), reselect(), none() (#69)
1 parent 99c5f67 commit 830ecc9

12 files changed

Lines changed: 468 additions & 181 deletions

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ If Docker is not available to you, or you would simply not use it, you will have
9494
```sh
9595
composer style-check
9696
```
97+
and fix it with:
98+
```sh
99+
composer style-fix
100+
```
97101

98102
#### Static analysis
99103

lib/Model.php

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,16 @@ public static function select(): Relation
15991599
return static::Relation()->select(...func_get_args());
16001600
}
16011601

1602+
/**
1603+
* @return Relation<static>
1604+
*
1605+
*@see Relation::reselect()
1606+
*/
1607+
public static function reselect(): Relation
1608+
{
1609+
return static::Relation()->reselect(...func_get_args());
1610+
}
1611+
16021612
/**
16031613
* @see Relation::readonly()
16041614
*
@@ -1715,13 +1725,25 @@ public static function not(): Relation
17151725
}
17161726

17171727
/**
1728+
* @see Relation::all()
1729+
*
17181730
* @return Relation<static>
17191731
*/
17201732
public static function all(): Relation
17211733
{
17221734
return static::Relation()->all();
17231735
}
17241736

1737+
/**
1738+
* @see Relation::none()
1739+
*
1740+
* @return Relation<static>
1741+
*/
1742+
public static function none(): Relation
1743+
{
1744+
return static::Relation()->none();
1745+
}
1746+
17251747
/**
17261748
* @param RelationOptions $options
17271749
*
@@ -1743,15 +1765,16 @@ protected static function Relation(array $options = []): Relation
17431765
* ```
17441766
* YourModel::count('amount > 3.14159265');
17451767
* YourModel::count(['name' => 'Tito', 'author_id' => 1]));
1768+
* YourModel::count();
17461769
* ```
17471770
*
17481771
* @see find
17491772
*
17501773
* @return int Number of records that matched the query
17511774
*/
1752-
public static function count(/* ... */): int
1775+
public static function count(): int
17531776
{
1754-
return static::Relation()->count(...func_get_args());
1777+
return static::Relation()->count();
17551778
}
17561779

17571780
/**
@@ -1764,12 +1787,32 @@ public static function exists(mixed $conditions = []): bool
17641787
return static::Relation()->exists($conditions);
17651788
}
17661789

1790+
/**
1791+
* @see Relation::pluck()
1792+
*
1793+
* @return array<static>
1794+
*/
1795+
public static function pluck(): array
1796+
{
1797+
return static::Relation()->pluck(...func_get_args());
1798+
}
1799+
1800+
/**
1801+
* @see Relation::ids()
1802+
*
1803+
* @return array<mixed>
1804+
*/
1805+
public static function ids(): array
1806+
{
1807+
return static::Relation()->ids();
1808+
}
1809+
17671810
/**
17681811
* @see Relation::take()
17691812
*
17701813
* @return static|array<static>|null
17711814
*/
1772-
public static function take(int $limit = null): Model|array|null
1815+
public static function take(int $limit = null): static|array|null
17731816
{
17741817
return static::Relation()->take($limit);
17751818
}
@@ -1779,7 +1822,7 @@ public static function take(int $limit = null): Model|array|null
17791822
*
17801823
* @return static|array<static>|null
17811824
*/
1782-
public static function first(int $limit = null): Model|array|null
1825+
public static function first(int $limit = null): static|array|null
17831826
{
17841827
return static::Relation()->first($limit);
17851828
}
@@ -1789,7 +1832,7 @@ public static function first(int $limit = null): Model|array|null
17891832
*
17901833
* @return static|array<static>|null
17911834
*/
1792-
public static function last(int $limit = null): Model|array|null
1835+
public static function last(int $limit = null): static|array|null
17931836
{
17941837
return static::Relation()->last($limit);
17951838
}

0 commit comments

Comments
 (0)