File: D:/HostingSpaces/SBogers85/equichecker.com/app/Listeners/SaveSearchDataOnDebtorSearch.php
<?php
namespace App\Listeners;
use App\Events\SearchDebtors;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use KommaApp\Stats\StatsService;
class SaveSearchDataOnDebtorSearch implements ShouldQueue
{
private $statsService;
/**
* Create the event listener.
*
* @param StatsService $statsService
* @return void
*/
public function __construct(StatsService $statsService)
{
$this->statsService = $statsService;
}
/**
* Handle the event.
*
* @param SearchDebtors $event
* @return void
*/
public function handle(SearchDebtors $event)
{
//use the statsService to save the search statistics, with the search term, found debtors and the current customer
$this->statsService->saveSearchStats($event->search_term, $event->debtors, $event->customer);
}
}