Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions database/factories/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Laravel\Passport\Client;
use Laravel\Passport\Passport;

class ClientFactory extends Factory
{
Expand All @@ -22,15 +23,32 @@ class ClientFactory extends Factory
*/
public function definition()
{
return [
return $this->ensurePrimaryKeyIsSet([
'user_id' => null,
'name' => $this->faker->company,
'secret' => Str::random(40),
'redirect' => $this->faker->url,
'personal_access_client' => false,
'password_client' => false,
'revoked' => false,
];
]);
}

/**
* Ensure the primary key is set on the model when using UUIDs.
*
* @param array $data
* @return array
*/
protected function ensurePrimaryKeyIsSet(array $data)
{
if (Passport::clientUuids()) {
$keyName = (new $this->model)->getKeyName();

$data[$keyName] = (string) Str::orderedUuid();
}

return $data;
}

/**
Expand Down