G
G
GaserV2017-08-23 15:47:38
Laravel
GaserV, 2017-08-23 15:47:38

How to run a method in a controller using cron?

Such a task. You need to use cron to call a method in the controller that will carry out certain operations. How to implement it?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
U
UksusoFF, 2017-08-23
@UksusoFF

Why don't you like the queue?

M
Mokhirjon Naimov, 2017-08-23
@zvermafia

Try like this:

app('App\Http\Controllers\PrintReportController')->getPrintReport();

A
ajaxtelamonid, 2017-08-23
@ajaxtelamonid

Separate the code that does something in the controller method into a separate class, for example, in the App\Services namespace, which you put in the app\Services folder. Include it in both the controller constructor and the command constructor. And call the desired method with this functionality both in the controller and in the command.
All other methods, such as, God forgive me, calling a GET request from cron, are hellish shit code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question