K
K
Kamol2016-03-09 14:11:39
Laravel
Kamol, 2016-03-09 14:11:39

How is this done in laravel?

Good day.
There is an entity Images. And I use this entity for all others, i.e. and to save the user's photo and for the product, Images is used. Their connection is many to many.
Now the question is: where can I shove such logic into laravel: at the input I receive a request file, then I resize it and move it to a specific directory, and I will use this logic for all entities in order to avoid duplication.
I understand that in laravel the use of one controller in another controller is undesirable, well, it's kind of wrong to do this. I thought to use the command bus, but unfortunately they replaced it with jobs, I understand that jobs are not for these purposes, they are, as it were, mainly used with queues. Of course, I can use trait, but I want to use the built-in laravel mechanism, if of course they exist.
I want to hear how you organize such logic in your application I
use Laravel 5.2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-03-09
@H_Kamol

Your options are:
1. Use your service as suggested by Anatoliy Lyovkin .
2. Use Job.
3. Use the model.
4. Use a separate route for uploading files and do everything in the controller.
Each of them has its pros and cons and each has the right to life.
Personally, I, solving exactly the same problem, used the latter option, since I need to show thumbnails of pictures when loading.

I thought to use the command bus, but unfortunately they replaced it with jobs, I understand that jobs are not for these purposes, they are, as it were, mainly used with queues.
They were just renamed. The meaning of this has not changed at all, it's just that now they are more difficult to confuse with console commands. Do this or through file model methods, e.g.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question