Skip to content

Commit f3d096d

Browse files
committed
Throw exception if there are no personal access clients
1 parent d9227de commit f3d096d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/ClientRepository.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Laravel\Passport;
44

5+
use RuntimeException;
6+
57
class ClientRepository
68
{
79
/**
@@ -77,6 +79,7 @@ public function activeForUser($userId)
7779
* Get the personal access token client for the application.
7880
*
7981
* @return \Laravel\Passport\Client
82+
* @throws RuntimeException
8083
*/
8184
public function personalAccessClient()
8285
{
@@ -86,6 +89,10 @@ public function personalAccessClient()
8689

8790
$client = Passport::personalAccessClient();
8891

92+
if (! $client->exists()) {
93+
throw new RuntimeException('Personal access client not found. Please create one first.');
94+
}
95+
8996
return $client->orderBy($client->getKeyName(), 'desc')->first()->client;
9097
}
9198

0 commit comments

Comments
 (0)