T
T
tushev2020-06-20 20:22:26
CRUD
tushev, 2020-06-20 20:22:26

How to make applications with forms and CRUD operations on Laravel?

I often have to develop typical web applications with many forms and CRUD operations. For example, any custom CRM or accounting systems. Usually these are several dozen forms, with hundreds of different fields and dozens of tables. Each form is associated with one or more tables in the database.

Laravel tutorials usually write about the same thing. For each model, you need to: create a migration, make a seeder, create a model, create a controller with the necessary operations, lay out a form with fields, do validation (perhaps a separate request-class in turn), register routes, make tests .. etc. Those. all this is spread over different files, classes.

The most difficult thing is that with any change in the set of fields, all this constantly has to be edited in different places. And with the active development and development of the project, all this changes regularly.

Of course, this is not a problem when creating a simple blog, as is usually seen in the examples. But in a real, not the simplest application, if this is done manually for each model, it will take a lot of time and lead to constant errors. Generally very inefficient.
How should such problems be dealt with?

Previously, I used my bicycles, which allowed me to declaratively describe all fields, forms, relationships and operations in a single place. When the requirements for the application changed, it was enough to make corrections in one place, and everything else (models, controllers, form templates...) automatically picked up the new configuration.

What is the correct path to use in Laravel?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Daria Motorina, 2020-06-20
@glaphire

The correct path is not tied to a framework, it is worth creating some kind of logical core (core module) and creating implementation modules based on it. You can write a private Laravel package that will combine all the logic of code generation and configuration in a standardized way

J
jazzus, 2020-06-21
@jazzus

Those. all this is spread over different files, classes.

If this concept does not suit you, there is no point in using Laravel.
The most difficult thing is that with any change in the set of fields, all this constantly has to be edited in different places.

The IDE should have file navigation when you write part of the path and a list opens up for you. For this to work, the names must be clear and simple.
if you do it manually for each model, it will take a lot of time

It takes a lot of time to support bikes. In Laravel, a new field is added in 5 minutes. Migration to add a field, add validation to the request file. Add an input to the front. Everything. Which bike will save you from these actions? No. Everywhere you need to write validation, add a field to the database and to the front.
and lead to permanent errors

To avoid errors, you need to write tests. Those. before adding a field, write a comprehensive test including validation and relax. it will lead you to the result almost without the need to think. Plus will check in the future.
What is the correct path to use in Laravel?

The correct path is indicated by Laravel itself. See docks. You need to use Laravel and not write bicycles or write bicycles, and leave Laravel alone)

I
Igor Vorotnev, 2020-06-25
@HeadOnFire

- Customization of default stubs
- https://github.com/laravel-shift/blueprint
- Custom commands for artisan that automate many steps
- Custom packages that take on heavy lifting and provide a convenient API for work
You are a programmer. A framework is not a rigid framework in which you are clamped. It's a flexible framework on which you build exactly what you need. So, whichever is more convenient for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question