E
E
Elsa122018-08-01 22:29:48
Software design
Elsa12, 2018-08-01 22:29:48

How to properly use controller methods in laravel to be called in another controller?

Hello! Such a question, I write on the site adding articles and I want the method of creating an alert to be called during the addition of the article, which somehow works. Suppose he just adds a record to the database.
How to correctly implement this addition? I have several methods for creating an alert and I want them all to be combined somewhere in one place, for this I created a controller. This is where the idea came from the article adding controller to call the desired method from the notification controller, is that correct? If yes, what is the best way to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-08-01
@Elsa12

No, you don't have to do that. Move the code to the service class and pull it from both controllers. And in general, the logic in the controllers is not good.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question