Skip to content
Snippets Groups Projects
LogTrainingEventListener.php 647 B
<?php


namespace App\Listeners;

use App\Events\LogTrainingEvent;
use App\Log;
use Illuminate\Contracts\Queue\ShouldQueue;

class LogTrainingEventListener implements ShouldQueue
{
    //public $queue = 'default';
    protected $log;

    public function __construct(Log $log)
    {
        $this->log = $log;
    }

    public function onLog($event)
    {
        $log = new Log();
        $log->fill($event->records['formatted']);
        $log->save();
    }

    public function subscribe($events)
    {
        $events->listen(
            LogTrainingEvent::class,
            'App\Listeners\LogTrainingEventListener@onLog'
        );
    }
}