<?php

namespace App\Dao\Report;

use App\Models\Report\ReportLog;

class ReportDao
{
    /**
     * @param $data
     * @return false
     */
    public function saveReportLog($data): bool
    {
        if (empty($data)) {
            return false;
        }

        return ReportLog::insert($data);
    }

    /**
     * @param $clickId
     * @param $eventType
     * @return array
     */
    public function getReportLogByClickId($clickId, $eventType): array
    {
        if (empty($clickId)) {
            return [];
        }

        $result = ReportLog::select('id', 'clickid', 'projectid', 'promotionid', 'uid')
                           ->where('clickid', $clickId)
                           ->where('event_type', $eventType)
                           ->first();
        return $result ? $result->toArray() : [];
    }
}