Skip to content

Commit f2c9e47

Browse files
erikaraujobrendt
andauthored
feat(database): add count() helper to IsDatabaseModel trait (#1181)
Co-authored-by: Brent Roose <[email protected]>
1 parent 62f45c3 commit f2c9e47

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/database/src/IsDatabaseModel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Tempest\Database;
66

7+
use Tempest\Database\Builder\QueryBuilders\CountQueryBuilder;
78
use Tempest\Database\Builder\QueryBuilders\SelectQueryBuilder;
89
use Tempest\Database\Exceptions\MissingRelation;
910
use Tempest\Database\Exceptions\MissingValue;
@@ -60,6 +61,11 @@ public static function find(mixed ...$conditions): SelectQueryBuilder
6061
return $query;
6162
}
6263

64+
public static function count(): CountQueryBuilder
65+
{
66+
return query(self::class)->count();
67+
}
68+
6369
public static function create(mixed ...$params): self
6470
{
6571
model(self::class)->validate(...$params);

0 commit comments

Comments
 (0)