<?php

namespace App\Modules\Activity\Models;

use Illuminate\Database\Eloquent\Model;

class ActivityStats extends Model
{
    protected $table = 'qapp_activity_stats';
    protected $fillable = ['id', 'activity_id', 'channel_id', 'success_order_num', 'recharge_amount',
        'order_num', 'pv', 'uv', 'paid_user_num'];

    public static function getActivityStatsByActivityIds($activityIds)
    {
        if (empty($activityIds)) {
            return [];
        }

        $result = self::whereIn('activity_id', $activityIds)->get();
        return $result ? $result->toArray() : [];
    }

    public static function insertData($data)
    {
        if (empty($data)) {
            return false;
        }

        return self::insert($data);
    }

    public static function updateData($where, $data)
    {
        if (empty($where) || empty($data)) {
            return false;
        }

        return self::where($where)->update($data);
    }
}
