laravel-idea / plugin

Laravel Idea plugin for PhpStorm
https://laravel-idea.com/
175 stars 7 forks source link

[Feature Request]: API crud generation base on migration files #769

Open beshoo opened 1 year ago

beshoo commented 1 year ago

Feature Description

I am a Laravel developer and I have been using PHPStorm for my development work. I have found that creating API CRUD operations for my Laravel models can be a repetitive and time-consuming task.

I was wondering if you could consider adding a feature to PHPStorm that would allow for API CRUD generation based on migration files.

The idea would be to have PHPStorm scan the migration files for a given model and automatically generate the corresponding CRUD operations for that model's API. This would save developers a lot of time and effort, as they would no longer have to manually create these operations.

I believe this feature would be a valuable addition to PHPStorm, and I would be very interested in using it in my development work. If this is something that you could consider adding to PHPStorm, I would be happy to provide any additional information or feedback that you may need.

Thank you for your time and consideration.

Best regards,

adelf commented 1 year ago

It's possible to create these controllers by New Model UI. I can try to add this feature to the existing models...

beshoo commented 1 year ago

Thanks for letting me know! Honestly, if you can add this feature to the existing models, it would be a huge time-saver. I spend much time doing CRUD operations with validations, so any help in that area would be fantastic. such as :

  public function store(Request $request)
    {
        $validator = Validator::make(
            $request->all(),
            [
                'title' => 'required|string|max:255',
                'data' => 'required|json',
            ]
        );

        if ($validator->fails())
        {
            return response()->json(['success'=> false,'errors' => $validator->errors()->all()],400);
        }

        $reportGenerator = new ReportGenerator();
        $reportGenerator->title = $request->input('title');
        $reportGenerator->data = $request->input('data');
        $reportGenerator->save();

        return response()->json(['success'=> true]);
    }

When you have 30 APIs, this will be such a boring process.

It would be great if we could have the option to create CRUD form migrations with validations since you already have validation creation. (You can add it as an option when we are creating the module)

However, I would prefer the validation included within the function instead of having it in a separate request file. Thank you!

beshoo commented 1 year ago

@adelf, I wanted to take a moment to express my appreciation for Laravel-idea and how it has revolutionized my development workflow. Your plugin has been incredibly helpful in saving me time and improving my productivity, and I'm constantly discovering new ways in which it streamlines my work processes.

In particular, I find your idea for generating API CRUD operations based on migration files to be very exciting and promising. I believe this would be a fantastic addition to an already outstanding plugin. As such, I was wondering if you could provide any hints or updates on whether this feature might be included in the next version of Laravel-idea.

Once again, thank you for all the hard work you put into Laravel-idea. Your dedication to providing developers with powerful and efficient tools is greatly appreciated.

Warm regards,

beshoo commented 1 year ago

@adelf any expected ETA for this wonderful functionality?

adelf commented 1 year ago

I hope I'll implement it in July. There are some difficulties like some devs use Model::create($request->validated()) this model creation code, but others prefer to describe each field, as in your code. So, it should be well-configurable.