pass user object to create text use case

drop UserRepository dependency; controller now passes the
authenticated User directly via CreateTextRequest, eliminating
a redundant repository lookup.
This commit is contained in:
Yisroel Baum 2026-05-02 21:27:32 +03:00
parent ffef0ddff6
commit bf006220e8
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
2 changed files with 7 additions and 0 deletions

View file

@ -24,9 +24,13 @@ class CreateText
if ($request->name === null) { if ($request->name === null) {
throw new BadRequestException('name is required'); throw new BadRequestException('name is required');
} }
if ($request->user === null) {
throw new BadRequestException('user is required');
}
$text = $this->textRepo->create(new CreateTextDto( $text = $this->textRepo->create(new CreateTextDto(
name: $request->name, name: $request->name,
user: $request->user,
)); ));
$this->nodeRepo->create(new CreateNodeDto( $this->nodeRepo->create(new CreateNodeDto(

View file

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