<?php

namespace App\Repositories\Shop;

use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

use Yajra\DataTables\DataTables;

use App\Models\Shop\Tax;

class Taxes
{

    public static function getOptions()
    {
        return Tax::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
    }

    public static function getAll()
    {
        return Tax::orderBy('value', 'asc')->get();
    }

    public static function get($id)
    {
        return Tax::find($id);
    }

    public static function store($data)
    {
        $id = isset($data['id']) ? $data['id'] : false;
        $item = $id ? self::update($data) : self::create($data);
        return $item->id;
    }

    public static function create($data)
    {
        return Tax::create($data);
    }

    public static function update($data, $id = false)
    {
        $id = $id ? $id : $data['id'];
        $item = self::get($id);
        $item->update($data);
        return $item;
    }

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