SaveQueryLogJob.php
825 Bytes
<?php
namespace Daito\Lib\QueryLog\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Bus\Queueable;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
class SaveQueryLogJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $arrQueries;
public function __construct(array $arrQueries)
{
$this->arrQueries = $arrQueries;
}
public function handle(): void
{
if ($this->arrQueries === array()) {
return;
}
DB::connection(config('query_log.connection', 'query_log'))
->table(config('query_log.table', 'log_queries'))
->insert($this->arrQueries);
}
}