-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Acme\Application\ShowUserProfile\ShowUserProfileUseCase; | ||
use Acme\Application\ShowUserProfile\ShowUserProfileUseCaseInput; | ||
use App\Models\User; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
final class ProfileController extends Controller | ||
{ | ||
public function __invoke(ShowUserProfileUseCase $useCase): View | ||
{ | ||
/** @var User $user */ | ||
$user = Auth::user(); | ||
$input = new ShowUserProfileUseCaseInput($user->username); | ||
$output = $useCase->show($input); | ||
|
||
return view('profile', [ | ||
'username' => $output->username, | ||
'email' => $output->email, | ||
]); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/packages/Acme/Application/ShowUserProfile/ShowUserProfileUseCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Acme\Application\ShowUserProfile; | ||
|
||
use Acme\Domain\User\Username; | ||
use Acme\Domain\User\UserRepository; | ||
|
||
final class ShowUserProfileUseCase | ||
{ | ||
public function __construct(private UserRepository $userRepository) | ||
{ | ||
} | ||
|
||
public function show(ShowUserProfileUseCaseInput $input): ShowUserProfileUseCaseOutput | ||
{ | ||
$username = new Username($input->username); | ||
$authUser = $this->userRepository->findByUsername($username); | ||
|
||
return new ShowUserProfileUseCaseOutput($authUser->username(), $authUser->email()); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/packages/Acme/Application/ShowUserProfile/ShowUserProfileUseCaseInput.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Acme\Application\ShowUserProfile; | ||
|
||
final readonly class ShowUserProfileUseCaseInput | ||
{ | ||
public function __construct(public string $username) | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/packages/Acme/Application/ShowUserProfile/ShowUserProfileUseCaseOutput.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Acme\Application\ShowUserProfile; | ||
|
||
final readonly class ShowUserProfileUseCaseOutput | ||
{ | ||
public function __construct( | ||
public string $username, | ||
public string $email, | ||
) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@extends('layouts.app') | ||
|
||
@section('title', 'プロフィール') | ||
|
||
@section('content') | ||
<h1>プロフィール</h1> | ||
|
||
<ul> | ||
<li>ユーザー名: {{ $username }}</li> | ||
<li>メールアドレス: {{ $email }}</li> | ||
</ul> | ||
|
||
<p><a href="{{ route('dashboard') }}">ダッシュボードへ戻る</a></p> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters