Skip to content

Instantly share code, notes, and snippets.

@ydenissov
Created October 30, 2022 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ydenissov/a92c95a7c3c8e417f8451f91cf092d55 to your computer and use it in GitHub Desktop.
Save ydenissov/a92c95a7c3c8e417f8451f91cf092d55 to your computer and use it in GitHub Desktop.
Job for write logs
<?php
namespace App\Jobs;
use App\Http\Controllers\LogController;
use App\Http\Controllers\TelegramBotController;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CalendarLogJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private array $data;
public function __construct($data)
{
$this->data = $data;
$this->onQueue('calendar_log_job');
}
public function handle()
{
$run_job = new LogController();
$run_job->writeLog($this->data);
}
public function failed(\Exception $exception)
{
$whats_wrong = $exception->getMessage();
$text_for_tg = 'Error Job. ' . $whats_wrong;
$send_message = new TelegramBotController();
$send_message->sendMessage(config('settings.telegram_notify_job_user_id'), $text_for_tg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment