PHP code example of haythem-bekir / laravel-discord-logger
1. Go to this page and download the library: Download haythem-bekir/laravel-discord-logger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
haythem-bekir / laravel-discord-logger example snippets
use Illuminate\Support\Facades\Schedule;
Schedule::command('discord-logger:daily-report')->dailyAt('08:00');
protected function schedule(Schedule $schedule): void
{
$schedule->command('discord-logger:daily-report')->dailyAt('08:00');
}
use HaythemBekir\DiscordLogger\Application\DailyReport\GatherLogStatisticsAction;
use HaythemBekir\DiscordLogger\Application\DailyReport\BuildDailyReportAction;
use HaythemBekir\DiscordLogger\Application\DailyReport\SendDailyReportAction;
use Carbon\Carbon;
class CustomReportService
{
public function __construct(
private GatherLogStatisticsAction $gather,
private BuildDailyReportAction $build,
private SendDailyReportAction $send,
) {}
public function sendWeeklyDigest(): void
{
$dates = collect(range(0, 6))->map(fn($days) => Carbon::now()->subDays($days));
foreach ($dates as $date) {
$stats = $this->gather->execute($date);
$report = $this->build->execute($stats);
$this->send->execute($report);
}
}
}