2

I was wondering if this would be a way to go to create a command for a task, or at least if t would work? Thanks in advance!

$schedule->command('someCommand')
         ->call('Path\To\MyController@method'{ 
          })
         ->dailyAt('00:00');
1
  • if my answer was helpful, please choose it as best answer. Commented Mar 21, 2016 at 15:14

1 Answer 1

2

Yes, there is a way to create your own custom commands. Read this tutorial to create your own artisan command: https://laravel.com/docs/5.1/artisan

Sign up to request clarification or add additional context in comments.

5 Comments

What do I put in the command file, the whole logic of my controller method or I just call my method from the command file?
If you already have logic in your controller which you use, then just call it from a command class.
Or maybe it would be even better to put all the logic from the controller to a third class, and call it from both command and controller when you need it. (because both command and controller are just an interface to interact with the app).
So, if I would call my method from the command class, would that then look like this? First list path to my controller where I list the classes that I use and then in: public function handle() { $this->mymethod(); }
What if I wanted to make a method call to execute only at a certain time. How would I do that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.