Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the result as an array (or object array) #9

Closed
rap2hpoutre opened this issue Jan 10, 2018 · 5 comments
Closed

Get the result as an array (or object array) #9

rap2hpoutre opened this issue Jan 10, 2018 · 5 comments

Comments

@rap2hpoutre
Copy link

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.

@rap2hpoutre
Copy link
Author

rap2hpoutre commented Jan 10, 2018

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().

@hmazter
Copy link
Owner

hmazter commented Jan 11, 2018

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

$rows[] = [
'expression' => $event->getExpression(),
'next run at' => $this->getNextRunDate($event),
'command' => $isVerbosityNormal ? $shortCommand : $fullCommand,
'description' => $description,
];
And then use that in the command

@hmazter
Copy link
Owner

hmazter commented Jan 11, 2018

This is a first, very basic attempt to what you may ask: #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

@hmazter
Copy link
Owner

hmazter commented Mar 9, 2018

Now available in v1.0.0

@hmazter hmazter closed this as completed Mar 9, 2018
@rap2hpoutre
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants