Skip to content

Commit 2d41404

Browse files
committed
refactor(database): remove resolve query builder method
1 parent 7fec4fa commit 2d41404

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

packages/database/src/Builder/ModelQueryBuilder.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,25 +145,6 @@ public function findById(string|int|PrimaryKey $id): object
145145
return $this->get($id);
146146
}
147147

148-
/**
149-
* Finds a model instance by its ID.
150-
*
151-
* **Example**
152-
* ```php
153-
* model(User::class)->resolve(1);
154-
* ```
155-
*
156-
* @return TModel
157-
*/
158-
public function resolve(string|int|PrimaryKey $id): object
159-
{
160-
if (! inspect($this->model)->hasPrimaryKey()) {
161-
throw ModelDidNotHavePrimaryColumn::neededForMethod($this->model, 'resolve');
162-
}
163-
164-
return $this->get($id);
165-
}
166-
167148
/**
168149
* Gets a model instance by its ID, optionally loading the given relationships.
169150
*

tests/Integration/Database/Builder/ModelQueryBuilderTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -168,30 +168,6 @@ public function test_new(): void
168168
$this->assertSame('Fern', $modelWithoutId->name);
169169
}
170170

171-
public function test_resolve_with_id_model(): void
172-
{
173-
$this->migrate(CreateMigrationsTable::class, TestModelWrapperMigration::class);
174-
175-
$created = model(TestUserModel::class)->create(name: 'Stark');
176-
$resolved = model(TestUserModel::class)->resolve($created->id);
177-
178-
$this->assertInstanceOf(TestUserModel::class, $resolved);
179-
$this->assertSame('Stark', $resolved->name);
180-
$this->assertTrue($created->id->equals($resolved->id));
181-
}
182-
183-
public function test_resolve_throws_for_model_without_id(): void
184-
{
185-
$this->migrate(CreateMigrationsTable::class, TestModelWithoutIdMigration::class);
186-
187-
$this->expectException(ModelDidNotHavePrimaryColumn::class);
188-
$this->expectExceptionMessage(
189-
"`Tests\Tempest\Integration\Database\Builder\TestUserModelWithoutId` does not have a primary column defined, which is required for the `resolve` method.",
190-
);
191-
192-
model(TestUserModelWithoutId::class)->resolve(1);
193-
}
194-
195171
public function test_get_with_id_model(): void
196172
{
197173
$this->migrate(CreateMigrationsTable::class, TestModelWrapperMigration::class);

0 commit comments

Comments
 (0)