<?php

namespace App\Services;

use App\CustomerLog;
use App\Traits\ServiceAppAop;


class CustomerLogService
{
    use ServiceAppAop;
    protected $modelClass=CustomerLog::class;
    public function get(array $params, array $withs=[])
    {
        $query = CustomerLog::query()->with($withs)->orderByDesc('id');
        foreach ($params as $column=>$param){
            if (is_array($param))$query->whereIn($column,$param);
            else $query->where($column,$param);
        }
        return $query->get();
    }

    public function update(array $params, array $values)
    {
        $query = CustomerLog::query();
        foreach ($params as $column=>$param){
            if (is_array($param))$query->whereIn($column,$param);
            else $query->where($column,$param);
        }
        return $query->update($values);
    }

    public function create(array $values)
    {
        return CustomerLog::query()->create($values);
    }

}
