Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b3471f31a0 |
@@ -32,8 +32,8 @@ trait SingleOrFail
|
|||||||
return NULL;
|
return NULL;
|
||||||
});
|
});
|
||||||
|
|
||||||
// When a query should return 1 object, or NULL if it doesnt
|
// When a query should return 1 object, or setup to create a new object
|
||||||
Builder::macro('singleOrNew',function ($args) {
|
Builder::macro('singleOrNew',function (array $args=[]) {
|
||||||
$result = $this->where($args)->get();
|
$result = $this->where($args)->get();
|
||||||
|
|
||||||
if ($result->count() == 1)
|
if ($result->count() == 1)
|
||||||
|
Reference in New Issue
Block a user