Closed rap2hpoutre closed 6 years ago
OK, I think I found a way to do this (return a collection with data from Scheduler).
I could make a PR about it.
I propose to create a helper for this: are you OK with schedule_list
? (a helper seems simpler than create a class for this, but as you want: I can also create a class with a method like Hmazter\LaravelScheduleList\ScheduleList::all()
or (new Hmazter\LaravelScheduleList\ScheduleList)->all()
.
I get all the data from \Illuminate\Console\Scheduling\Schedule::events
and that is public if you just need the raw data. But I guess you are after some of the formatted and parsed data that I have?
I could extract the logic with a public getter to a class, which would return pretty much this data https://github.com/hmazter/laravel-schedule-list/blob/8f68139ab3b664f36c3eddf1ff710bbaecdd889c/src/Console/ListScheduler.php#L118-L123 And then use that in the command
This is a first, very basic attempt to what you may ask: https://github.com/hmazter/laravel-schedule-list/pull/10
With this you could do:
$scheduledEvents = app()->make(ScheduleList::class)->all(); // or use injection
$scheduledEvents
would then contain all the scheduled events with all the parsed and formatted data previously used in the command line output
Now available in v1.0.0
Thanks!
It could be great to add an helper function (or something like that) to get the scheduled tasks as an array. So we could display it in a web interface, or iterate over it to check some things.