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:
parent
ffef0ddff6
commit
bf006220e8
2 changed files with 7 additions and 0 deletions
|
|
@ -24,9 +24,13 @@ class CreateText
|
|||
if ($request->name === null) {
|
||||
throw new BadRequestException('name is required');
|
||||
}
|
||||
if ($request->user === null) {
|
||||
throw new BadRequestException('user is required');
|
||||
}
|
||||
|
||||
$text = $this->textRepo->create(new CreateTextDto(
|
||||
name: $request->name,
|
||||
user: $request->user,
|
||||
));
|
||||
|
||||
$this->nodeRepo->create(new CreateNodeDto(
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
namespace App\Text\UseCases;
|
||||
|
||||
use App\User\User;
|
||||
|
||||
class CreateTextRequest
|
||||
{
|
||||
public function __construct(
|
||||
public ?string $name,
|
||||
public ?User $user,
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue