ridewn's avatar

Laravel 5 commands and eloquent objects

Hi everyone, I'm a bit confused as to what a command should exactly do. I get that it is an instruction, but say I have a method in my controller to upload a file, and an image to go along with that file. So I create a UploadFiles command, and have the logic to upload the files and image. My question is: should I have the logic to create the model in the database in the command or still in my controller? Or should it be an event? As far as I know you can't return anything from those classes, so I don't know if I'm missing something or if I do keep it in my controller.

0 likes
1 reply
adar's avatar
adar
Best Answer
Level 2

In a great simplification, Command is to move data to other place, do something and launch event. To create model you should create Service and use it in handler, by me.

3 likes

Please or to participate in this conversation.