<?php

namespace App\Repositories\Sale;

use App\Models\SaleDetail;
use App\Models\Sales;
use App\Repositories\Sale\SaleRepositoryInterface;

class SaleRepository implements SaleRepositoryInterface
{
    public function create(array $data){
        return Sales::create($data);
    }
    public function find($id){
        return Sales::find($id);
    }
    public function update($id, $data){
        return Sales::find($id)->update($data);
    }
    public function delete($id){
        return Sales::find($id)->delete();
    }
    public function all(){
        return Sales::all();
    }
    public function allquery(){
        return Sales::query();
    }
    public function restore($id){
        return Sales::withTrashed()->find($id)->restore();
    }
    public function getByOpportunity($id){
        return Sales::where('opportunity_id', $id)->first();
    }
    public function generateDetailSale($data){
        return SaleDetail::create($data);
    }
}
