feat: ship creator journey v2 and profile updates
This commit is contained in:
37
app/Http/Controllers/Api/ProfileJourneyController.php
Normal file
37
app/Http/Controllers/Api/ProfileJourneyController.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Services\Profile\CreatorJourneyService;
|
||||
use App\Support\UsernamePolicy;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
final class ProfileJourneyController extends Controller
|
||||
{
|
||||
public function __construct(private readonly CreatorJourneyService $journeys)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(string $username): JsonResponse
|
||||
{
|
||||
$normalized = UsernamePolicy::normalize($username);
|
||||
|
||||
$user = User::query()
|
||||
->whereRaw('LOWER(username) = ?', [$normalized])
|
||||
->where('is_active', true)
|
||||
->whereNull('deleted_at')
|
||||
->firstOrFail();
|
||||
|
||||
return response()->json([
|
||||
'data' => $this->journeys->publicPayloadForUser($user),
|
||||
'meta' => [
|
||||
'username' => (string) $user->username,
|
||||
'generated_at' => now()->toIso8601String(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user