You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.1 KiB
73 lines
2.1 KiB
<?php
|
|
|
|
namespace App\Listeners;
|
|
|
|
use App\Events\ModelSaved;
|
|
use App\Models\Activity;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ActivityRegistration implements ShouldQueue
|
|
{
|
|
/**
|
|
* If your queue connection's after_commit configuration option is set to true,
|
|
* indicate that a particular queued listener should be dispatched after all database transactions closed
|
|
*
|
|
* @var boolean
|
|
*/
|
|
public $afterCommit = true;
|
|
|
|
/**
|
|
* The name of the connection the job should be sent to.
|
|
*
|
|
* @var string|null
|
|
*/
|
|
public $connection = 'redis';
|
|
|
|
/**
|
|
* The name of the queue the job should be sent to.
|
|
* It's just a name and if don't set it, laravel use default queue name in the connection
|
|
*
|
|
* @var string|null
|
|
*/
|
|
public $queue = 'activities';
|
|
|
|
/**
|
|
* Create the event listener.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Handle the event.
|
|
*
|
|
* @param ModelSaved $event
|
|
* @return void
|
|
*/
|
|
public function handle(ModelSaved $event)
|
|
{
|
|
Log::info('listener:'. json_encode($event->message));
|
|
$message = json_decode($event->message);
|
|
Activity::create([
|
|
'business_id' => $message->business,
|
|
'project_id' => $message->project,
|
|
'actor_id' => $message->auth,
|
|
'system_id' => $message->data->system_id,
|
|
'workflow_id' => $message->data->workflow_id,
|
|
'status_id' => $message->data->status_id,
|
|
'sprint_id' => $message->data->sprint_id,
|
|
'task_id' => $message->data->task_id ?? null,
|
|
'subject_id' => $message->data->subject_id ?? null,
|
|
'user_id' => $message->data->user_id,
|
|
'crud_id' => $message->data->crud_id,
|
|
'table_id' => enum('tables.'.$message->data->table_name.'.id'),
|
|
'original' => $message->data->original,
|
|
'diff' => $message->data->diff,
|
|
]);
|
|
}
|
|
}
|