<?php 

namespace App\Services; 

use App\Customer;

Class CustomerService
{
    public function getSelection($column = ['id', 'name'])
    {
        return Customer::query()->select($column)->get();
    }

    public function paginate()
    {
        return Customer::query()->orderByDesc('id')->paginate(50);
    }

    public function create(array $params)
    {
        return Customer::query()->create($params);
    }

    public function find($id)
    {
        return Customer::query()->find($id);
    }

    public function update(array $params, array $values)
    {
        $query = Customer::query();
        foreach ($params as $column => $value){
            $query->where($column,$value);
        }
        return $query->update($values);
    }

    public function destroy($id)
    {
        return Customer::destroy($id);
    }
}