add user to plan

This commit is contained in:
Yisroel Baum 2026-02-23 10:58:37 +02:00
parent 9c2f95eda1
commit 547558d850
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 18 additions and 0 deletions

View file

@ -2,9 +2,12 @@
namespace App\Plan;
use App\User\User;
class CreatePlanDto
{
public function __construct(
public string $name,
public User $user,
) {}
}

View file

@ -2,11 +2,14 @@
namespace App\Plan;
use App\User\User;
class Plan
{
public function __construct(
private int $id,
private string $name,
private User $user,
) {}
public function getId(): int
@ -18,4 +21,9 @@ class Plan
{
return $this->name;
}
public function getUser(): User
{
return $this->user;
}
}

View file

@ -5,17 +5,22 @@ namespace App\Plan\UseCases;
use App\Plan\CreatePlanDto;
use App\Plan\Plan;
use App\Plan\PlanRepository;
use App\User\UserRepository;
class CreatePlan
{
public function __construct(
private PlanRepository $planRepo,
private UserRepository $userRepo,
) {}
public function execute(CreatePlanRequest $request): Plan
{
$user = $this->userRepo->find($request->userId);
return $this->planRepo->create(new CreatePlanDto(
name: $request->name,
user: $user,
));
}
}

View file

@ -5,6 +5,7 @@ namespace App\Plan\UseCases;
class CreatePlanRequest
{
public function __construct(
public int $userId,
public string $name,
) {}
}