Deprecate singleOrNew(), we use firstOrNew() instead

This commit is contained in:
2024-11-12 21:03:47 +11:00
parent 24144de193
commit 521a9b0679
3 changed files with 3 additions and 13 deletions

View File

@@ -21,15 +21,5 @@ trait Single
return NULL;
});
// When a query should return 1 object, or NULL if it doesnt
Builder::macro('singleOrNew',function ($args) {
$result = $this->where($args)->get();
if ($result->count() === 1)
return $result->first();
return $this->newModelInstance($args);
});
}
}