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

@ -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,
) {}
}