Skip to content

Commit

Permalink
rename file
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 14, 2021
1 parent 3eb4b8b commit 86c7913
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Concerns/BuildsQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Container\Container;
use Illuminate\Database\MultipleRecordsFoundException;
use Illuminate\Database\NoRecordsFoundException;
use Illuminate\Database\RecordsNotFoundException;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;

Expand Down Expand Up @@ -150,24 +150,24 @@ public function first($columns = ['*'])
}

/**
* Execute the query and get the first result if it's the sole.
* Execute the query and get the first result if it's the sole matching record.
*
* @param array|string $columns
* @return \Illuminate\Database\Eloquent\Model|object|static|null
*
* @throws \Illuminate\Database\NoRecordsFoundException
* @throws \Illuminate\Database\RecordsNotFoundException
* @throws \Illuminate\Database\MultipleRecordsFoundException
*/
public function sole($columns = ['*'])
{
$result = $this->take(2)->get($columns);

if ($result->isEmpty()) {
throw new NoRecordsFoundException();
throw new RecordsNotFoundException;
}

if ($result->count() > 1) {
throw new MultipleRecordsFoundException();
throw new MultipleRecordsFoundException;
}

return $result->first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use RuntimeException;

class NoRecordsFoundException extends RuntimeException
class RecordsNotFoundException extends RuntimeException
{
//
}

0 comments on commit 86c7913

Please sign in to comment.