Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support auto generete with laravel-data #872

Open
1 task done
tanmnt opened this issue Jul 18, 2024 · 2 comments
Open
1 task done

Support auto generete with laravel-data #872

tanmnt opened this issue Jul 18, 2024 · 2 comments
Labels
enhancement New feature or request feature-request

Comments

@tanmnt
Copy link

tanmnt commented Jul 18, 2024

Scribe version

4.37.1

Your question

Is there a way I can auto-generate requests use laravel-data like using FormRequest?

  • UserController.php
    /**
     * Create user
     *
     * @apiResourcedResource status=201
     *
     * @apiResourceModel App\Models\User
     *
     * @apiResourceAdditional message="Create successfully!"
     */
    public function store(CreateUserDto $createUserDto): JsonResponse
    {
        // Create user
    }
  • CreateUserDto.php
class CreateUserDto extends Data
{
    public function __construct(public string $name, public string $email, public string $password, public int $role_id)
    {
    }

    public static function rules(): array
    {
        return [
            'name' => ['required', 'string', 'max:191'],
            'email' => ['required', 'string', 'email', 'max:191', Rule::unique('users')->withoutTrashed()],
            'role_id' => ['required', 'exists:roles,id'],
            'password' => [
                'required',
                'confirmed',
                'max:191',
                Password::min(8)->letters()->mixedCase()->symbols()->numbers(),
            ],
        ];
    }
}

Docs

@tanmnt tanmnt added question Further information is requested triage labels Jul 18, 2024
@shalvah
Copy link
Contributor

shalvah commented Jul 19, 2024

I think someone mentioned it once, but no, there are currently no plans. Feel free to add it!

@shalvah shalvah added enhancement New feature or request feature-request and removed question Further information is requested triage labels Jul 19, 2024
@kiboko-dev
Copy link

Very necessary functionality, because there are no developments supporting the current version of the Laravel Data package. And there is no desire to leave Scribe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature-request
Projects
None yet
Development

No branches or pull requests

3 participants