You don't need to mark something out as a service formally.
Just create a simple class that handles avatar creation. Don't overthink it.
Or you might want to look at Lucid ...
Hi all,
I'm trying to create a new app using laravel (5.6) as a framework and i'm having some trouble figuring out the structure should be.
The first problem I ran into is where you put most of the logic. I know there's been a lot of questions about this topic but i couldn't find an answer reading the forums. To be more precise, what I'm trying to do is save a user to the database. The user, when creating an account has the option to add an avatar image but it's not required to do so. If the user doesn't upload an avatar image, I'm creating one for him.
For this, in the controller I accept a FormRequest class as the param, witch validates the input, and then i call a repository->create() method.
Now, the repository should only be concerned with DB operations so the mothod for creating an avatar image for him should not be in the repository and I don;t know where to put it. I come from a symfony background where, from a controller you would call a service, with in turn would call a repository to store the data. In this service you could have more logic, even creating the avatar image for him.
In laravel though, I noticed there's no services so what do I have to do in order to achieve a clean design ? Would EventListeners be an option ? Creating and saving an image should be the model's/repository's responsability ?
Maybe I'm missing something about laravel app structure but the thing is I just started working with it and I didn't have the time to read all the docs (although I searched for this question a lot).
Some advice about this will be highly appreciated. Thanks
Please or to participate in this conversation.