diff --git a/src/Illuminate/Database/Concerns/BuildsQueries.php b/src/Illuminate/Database/Concerns/BuildsQueries.php index 9aa590654b83..38b04e8bcdcb 100644 --- a/src/Illuminate/Database/Concerns/BuildsQueries.php +++ b/src/Illuminate/Database/Concerns/BuildsQueries.php @@ -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; @@ -150,12 +150,12 @@ 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 = ['*']) @@ -163,11 +163,11 @@ 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(); diff --git a/src/Illuminate/Database/NoRecordsFoundException.php b/src/Illuminate/Database/RecordsNotFoundException.php similarity index 56% rename from src/Illuminate/Database/NoRecordsFoundException.php rename to src/Illuminate/Database/RecordsNotFoundException.php index b45266c8e9bf..3e0d9557581d 100755 --- a/src/Illuminate/Database/NoRecordsFoundException.php +++ b/src/Illuminate/Database/RecordsNotFoundException.php @@ -4,7 +4,7 @@ use RuntimeException; -class NoRecordsFoundException extends RuntimeException +class RecordsNotFoundException extends RuntimeException { // } diff --git a/tests/Integration/Database/QueryBuilderTest.php b/tests/Integration/Database/QueryBuilderTest.php index 0c7df7bbb124..675f30561fae 100644 --- a/tests/Integration/Database/QueryBuilderTest.php +++ b/tests/Integration/Database/QueryBuilderTest.php @@ -4,7 +4,7 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Illuminate\Database\MultipleRecordsFoundException; -use Illuminate\Database\NoRecordsFoundException; +use Illuminate\Database\RecordsNotFoundException; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; @@ -52,7 +52,7 @@ public function testSoleFailsForMultipleRecords() public function testSoleFailsIfNoRecords() { - $this->expectException(NoRecordsFoundException::class); + $this->expectException(RecordsNotFoundException::class); DB::table('posts')->where('title', 'Baz Post')->sole(); }