├── LICENSE
├── README.md
├── composer.json
├── pint.json
├── resources
└── views
│ └── livewire
│ └── schedule.blade.php
└── src
├── Livewire
└── Schedule.php
└── ScheduleServiceProvider.php
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Hosmel Quintana
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Pulse - Schedule
2 |
3 | Laravel Pulse card that list all scheduled tasks.
4 |
5 | 
6 |
7 | ## Installation
8 |
9 | You can install the package via composer:
10 |
11 | ```sh
12 | composer require hosmelq/laravel-pulse-schedule
13 | ```
14 |
15 | ## Usage
16 |
17 | To add the card to the Pulse dashboard, you must first [publish](https://laravel.com/docs/10.x/pulse#dashboard-customization) the dashboard view.
18 |
19 | ```sh
20 | php artisan vendor:publish --tag=pulse-dashboard
21 | ```
22 |
23 | You can now add the card.
24 |
25 | ```html
26 |
27 | ...
28 |
29 |
30 |
31 | ...
32 |
33 |
34 | ```
35 |
36 |
37 | ## Credits
38 |
39 | - [Hosmel Quintana](https://github.com/hosmelq)
40 | - [All Contributors](../../contributors)
41 |
42 | ## License
43 |
44 | The MIT License (MIT). Please see [License File](LICENSE) for more information.
45 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hosmelq/laravel-pulse-schedule",
3 | "description": "Laravel Pulse card that list all scheduled tasks.",
4 | "license": "MIT",
5 | "type": "library",
6 | "keywords": [
7 | "hosmelq",
8 | "laravel",
9 | "pulse",
10 | "laravel-pulse",
11 | "laravel-pulse-schedule"
12 | ],
13 | "authors": [
14 | {
15 | "name": "Hosmel Quintana",
16 | "email": "hosmelq@gmail.com"
17 | }
18 | ],
19 | "require": {
20 | "php": "^8.1",
21 | "laravel/framework": "^10.48.4|^11.0.8|^12.0",
22 | "laravel/pulse": "^1.4"
23 | },
24 | "require-dev": {
25 | "laravel/pint": "^1.10"
26 | },
27 | "minimum-stability": "dev",
28 | "prefer-stable": true,
29 | "autoload": {
30 | "psr-4": {
31 | "HosmelQ\\Laravel\\Pulse\\Schedule\\": "src/"
32 | }
33 | },
34 | "config": {
35 | "allow-plugins": {
36 | "pestphp/pest-plugin": true,
37 | "phpstan/extension-installer": true
38 | },
39 | "sort-packages": true
40 | },
41 | "extra": {
42 | "laravel": {
43 | "providers": [
44 | "HosmelQ\\Laravel\\Pulse\\Schedule\\ScheduleServiceProvider"
45 | ]
46 | }
47 | },
48 | "scripts": {
49 | "analyse": "phpstan analyse --configuration=phpstan.neon.dist --memory-limit=4G",
50 | "rector": "rector"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/pint.json:
--------------------------------------------------------------------------------
1 | {
2 | "preset": "psr12",
3 | "rules": {
4 | "array_indentation": true,
5 | "binary_operator_spaces": {
6 | "default": "single_space"
7 | },
8 | "cast_spaces": true,
9 | "class_attributes_separation": true,
10 | "concat_space": true,
11 | "declare_strict_types": true,
12 | "lambda_not_used_import": true,
13 | "method_chaining_indentation": true,
14 | "multiline_whitespace_before_semicolons": true,
15 | "no_extra_blank_lines": {
16 | "tokens": [
17 | "extra",
18 | "throw",
19 | "use"
20 | ]
21 | },
22 | "no_trailing_comma_in_singleline_array": true,
23 | "no_unneeded_import_alias": true,
24 | "no_unused_imports": true,
25 | "no_whitespace_before_comma_in_array": true,
26 | "not_operator_with_successor_space": true,
27 | "object_operator_without_whitespace": true,
28 | "ordered_imports": {
29 | "imports_order": [
30 | "const",
31 | "function",
32 | "class"
33 | ],
34 | "sort_algorithm": "alpha"
35 | },
36 | "single_import_per_statement": false,
37 | "single_quote": true,
38 | "trailing_comma_in_multiline": {
39 | "elements": ["arrays"]
40 | },
41 | "trim_array_spaces": true,
42 | "unary_operator_spaces": true,
43 | "whitespace_after_comma_in_array": true
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/resources/views/livewire/schedule.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | @empty($events)
9 |
10 | @else
11 |
12 |
13 |
14 | Task
15 | Next Due
16 | Expression
17 |
18 |
19 |
20 | @foreach($events as $event)
21 |
22 |
23 |
24 | {{ $event['command'] }} {{ $event['arguments'] }}
25 |
26 | {{ $event['next_due'] }}
27 | {{ $event['expression'] }} {{ $event['repeat_expression'] }}
28 |
29 | @endforeach
30 |
31 |
32 | @endempty
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/Livewire/Schedule.php:
--------------------------------------------------------------------------------
1 | 120);
19 |
20 | Artisan::call('schedule:list');
21 |
22 | ScheduleListCommand::resolveTerminalWidthUsing(null);
23 |
24 | $events = collect(explode("\n", Artisan::output()))
25 | ->filter()
26 | ->map(function (string $line): ?array {
27 | $pattern = '/^\s*([*0-9,-\/]+\s+[*0-9,-\/]+\s+[*0-9,-\/]+\s+[*0-9,-\/]+\s+[*0-9,-\/]+)(?:\s+(\d+s))?\s+(.+?)\s+\.+\s+Next Due:\s+(.+)$/';
28 |
29 | if (! preg_match($pattern, $line, $matches)) {
30 | return null;
31 | }
32 |
33 | $command = $matches[3];
34 |
35 | if (str_starts_with($command, 'php artisan')) {
36 | preg_match("#(php artisan [\w\-:]+)\s*(.+)?#", $command, $parts);
37 |
38 | $command = $parts[1] ?? 'no';
39 | $arguments = $parts[2] ?? '';
40 | } else {
41 | $arguments = '';
42 | }
43 |
44 | return [
45 | 'arguments' => $arguments,
46 | 'command' => $command,
47 | 'expression' => trim($matches[1]),
48 | 'next_due' => trim($matches[4]),
49 | 'repeat_expression' => $matches[2] ?? null,
50 | ];
51 | })
52 | ->filter();
53 |
54 | return view('pulse-schedule::livewire.schedule', [
55 | 'events' => $events,
56 | ]);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/ScheduleServiceProvider.php:
--------------------------------------------------------------------------------
1 | loadViewsFrom(__DIR__.'/../resources/views', 'pulse-schedule');
17 |
18 | $this->callAfterResolving('livewire', function (LivewireManager $livewire): void {
19 | $livewire->component('pulse.schedule', Schedule::class);
20 | });
21 | }
22 |
23 | /**
24 | * @return array
25 | */
26 | public function provides()
27 | {
28 | return [\Laravel\Pulse\Pulse::class];
29 | }
30 | }
31 |
--------------------------------------------------------------------------------