Back

You can make it even cleaner:

public function store(CreateUserRequest $request, CreateUser $action): RedirectResponse
{
auth()->login(
$action->execute($request->validated())
);

return to_route('dashboard');
}

1

31

For readability I would rather use it has @nunomaduro did, I would use invokable instead of execute as someone else mentioned

1

87

In response to @mp_programming

Because of insufficient syntax highlighting, my code variant doesn't look very good, but with normal highlighting it is very easy to read.

I like the option suggested by @nunomaduro, but I don't like to create extra variables unnecessarily. I just don't see the point of it. But I agree with Nuno about invokable classes - I'm not a fan.

Invokable class doesn't say anything about typing and IDE can't tell you how to pass data correctly.

70

  • No matching results...
  • Searching...

/ 1000