Deploy Ladill Hosting / deploy (push) Successful in 1m29s
Expose authenticated service endpoints for assigning, listing, renewing, and managing hosting accounts from the platform, with tests and deploy docs. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
678 B
PHP
32 lines
678 B
PHP
<?php
|
|
|
|
namespace App\Services\Platform;
|
|
|
|
use App\Models\User;
|
|
|
|
class PlatformUserResolver
|
|
{
|
|
public function resolveOrCreate(string $publicId, string $email = '', string $name = ''): ?User
|
|
{
|
|
$publicId = trim($publicId);
|
|
if ($publicId === '') {
|
|
return null;
|
|
}
|
|
|
|
$user = User::query()->where('public_id', $publicId)->first();
|
|
if ($user) {
|
|
return $user;
|
|
}
|
|
|
|
if ($email === '') {
|
|
return null;
|
|
}
|
|
|
|
return User::query()->create([
|
|
'public_id' => $publicId,
|
|
'email' => $email,
|
|
'name' => $name !== '' ? $name : $email,
|
|
]);
|
|
}
|
|
}
|