Created
October 30, 2022 18:40
-
-
Save ydenissov/a92c95a7c3c8e417f8451f91cf092d55 to your computer and use it in GitHub Desktop.
Job for write logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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