Skip to content

Commit 6a27368

Browse files
authored
feat: add virtual methods to SoftDeletes trait (#52001)
1 parent 903c702 commit 6a27368

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Illuminate/Database/Eloquent/SoftDeletes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @method static \Illuminate\Database\Eloquent\Builder<static> withTrashed(bool $withTrashed = true)
77
* @method static \Illuminate\Database\Eloquent\Builder<static> onlyTrashed()
88
* @method static \Illuminate\Database\Eloquent\Builder<static> withoutTrashed()
9+
* @method static static restoreOrCreate(array<string, mixed> $attributes = [], array<string, mixed> $values = [])
10+
* @method static static createOrRestore(array<string, mixed> $attributes = [], array<string, mixed> $values = [])
911
*
1012
* @mixin \Illuminate\Database\Eloquent\Model
1113
*/

types/Database/Eloquent/Model.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ function test(User $user): void
2020

2121
assertType('Illuminate\Database\Eloquent\Collection<int, User>', $user->newCollection([new User()]));
2222
assertType('Illuminate\Database\Eloquent\Collection<string, Illuminate\Types\Model\Post>', $user->newCollection(['foo' => new Post()]));
23+
24+
assertType('bool', $user->restore());
25+
assertType('User', $user->restoreOrCreate());
26+
assertType('User', $user->createOrRestore());
2327
}
2428

2529
class Post extends Model

0 commit comments

Comments
 (0)