Code cleanup, no functional changes
This commit is contained in:
@@ -55,7 +55,7 @@ trait EncodeUTF8
|
||||
|
||||
foreach ($properties as $property) {
|
||||
// Dont serialize the validation error
|
||||
if (($property->name == 'errors') || $property->isStatic())
|
||||
if (($property->name === 'errors') || $property->isStatic())
|
||||
continue;
|
||||
|
||||
$property->setAccessible(true);
|
||||
|
@@ -16,11 +16,10 @@ trait SingleOrFail
|
||||
Builder::macro('singleOrFail',function () {
|
||||
$result = $this->get();
|
||||
|
||||
if (($x=$result->count()) == 1) {
|
||||
if (($x=$result->count()) === 1)
|
||||
return $result->first();
|
||||
}
|
||||
|
||||
if ($x == 0)
|
||||
if ($x === 0)
|
||||
throw new ModelNotFoundException('Query brings back 0 record(s) called for singleOrFail()');
|
||||
else
|
||||
throw new \Exception(sprintf('Query brings back %d record(s) called for singleOrFail()',$x));
|
||||
@@ -30,9 +29,8 @@ trait SingleOrFail
|
||||
Builder::macro('single',function () {
|
||||
$result = $this->get();
|
||||
|
||||
if ($result->count() == 1) {
|
||||
if ($result->count() === 1)
|
||||
return $result->first();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
});
|
||||
@@ -41,11 +39,10 @@ trait SingleOrFail
|
||||
Builder::macro('singleOrNew',function ($args) {
|
||||
$result = $this->where($args)->get();
|
||||
|
||||
if ($result->count() == 1) {
|
||||
if ($result->count() === 1)
|
||||
return $result->first();
|
||||
}
|
||||
|
||||
return $this->newModelInstance($args);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user