D
D
Dmitry2017-05-24 00:57:12
Software design
Dmitry, 2017-05-24 00:57:12

Is this application structure acceptable?

The application on Laravel 5.4 has the following structure:
A number of "entities" are selected (perhaps I am not using this concept correctly), for example, such as "User( User)", "User's Messages( User\Message)", "User's Friends( User\Friend)".
Each entity, if necessary, has an implementation of Repository (using Eloquent), Service, FormModel.
Controller ( App\Http\Controllers\UsersController).
In the constructor, the services needed in this space are implemented.
Actions use services in which the logic has been rendered.
If the action requires request validation (for example, a form), the request (FormRequest) is added in the arguments.
Service ( App\Entities\User\Service).
Each service is bound in a DI container (a service provider with a primitive singleton bind is allocated for this task: i.imgur.com/GcIHzXY.png) by abstraction (interface, App\Interfaces).
A repository is injected into the service (on top of Eloquent, yes).
The service can validate models through an instance Illuminate\Validation\Validatorwith rules from any model that has advantages HasAttributes(attributes, rules(), errorMessages(), etc.).
repository( App\Entities\User\Repository).
Used to access data in the database. Repositories are bound in the same way as services, but in a separate service provider.
FormModel ( App\Entities\User\FormModel)
Similar to Eloquent, but no database connection, inherited from the Model base class, which uses HasAttributes, HasGuardedand a few more mixins.
It is used as a temporary storage when transporting data from a form to a database.
The model is filled ( fill()by content $fillable) with the data from the request and validated. Data is written to the database using the repository obtained from the model (usually enough $model->toArray()).
The base classes for the Service, Repository and Model are described (FormModel is inherited from it).
The base service contains a set of methods that are used in one way or another in all entities.
Similarly with the base repository and the base implementation of the model.
Service, repository and various "models" (FormModel, for example) are inherited from base implementations.
At the moment, some points are being optimized, of course, but in general, such a structure satisfies the requirements.
I looked towards DDD, but I think that this approach is redundant specifically in this situation.
Is using DDD a recommendation when designing a good application, or is it just one of the options? What other approaches exist?
What does your application look like in general terms?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question