iam-omer-mahdi / ss-v10

0 stars 0 forks source link

Validation can go into a separate class #2

Open ModestasV opened 1 year ago

ModestasV commented 1 year ago

I've noticed that you are using validation in the controller, for example:

https://github.com/iam-omer-mahdi/ss-v10/blob/main/app/Http/Controllers/StudentController.php#L80

While it's not a big deal - it adds complexity for your controller so it might be better to move it to its own Request class https://laravel.com/docs/10.x/validation#form-request-validation

That way, you'll have different responsibilities in different classes

ModestasV commented 1 year ago

As a bonus, in this scenario: https://github.com/iam-omer-mahdi/ss-v10/blob/main/app/Http/Controllers/StudentController.php#L100

You might be able to pass $request->validated() and you won't have to list all the fields.

This repeats on both files in same pattern where request validation can be extracted