Skip to content

Commit

Permalink
filter public holidays in belgium
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Jan 17, 2024
1 parent 13704a7 commit d7dcfc6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/Console/Commands/AfterworkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Carbon\CarbonInterval;
use Carbon\CarbonPeriod;
use Illuminate\Console\Command;
use Spatie\Holidays\Holidays;
use Spatie\SlackAlerts\Facades\SlackAlert;

class AfterworkCommand extends Command
Expand All @@ -20,7 +21,9 @@ public function handle(): void
->map(fn (string $option, int $index) => $this->addEmoji($option, $index))
->implode("\n");

SlackAlert::message("Who is in for an afterwork drink? :beer: :cup_with_straw:\n{$options}");
$this->info("Poll options:\n{$options}");

SlackAlert::message("Who is in for an afterwork drink? :beer:\n{$options}");

$this->info('Poll posted to Slack');
}
Expand All @@ -33,6 +36,10 @@ protected function generatePollOptions(): array
$datesInMonth = $this->getDatesForWeekdayInMonth($weekday);

foreach ($datesInMonth as $date) {
if (Holidays::new()->isHoliday($date, 'be')) {
continue;
}

$options[$date->day] = "{$date->shortDayName} {$date->day}/{$date->month}";
}
}
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"spatie/crypto": "^2.0.1",
"spatie/eloquent-sortable": "^4.0.1",
"spatie/fork": "^1.1.2",
"spatie/holidays": "^0.0.1",
"spatie/laravel-artisan-dispatchable": "^1.3",
"spatie/laravel-backup": "^8.1.5",
"spatie/laravel-comments": "^1.3",
Expand Down
62 changes: 61 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d7dcfc6

Please sign in to comment.