<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Invoice extends Model
{
    use HasFactory;

    public static function newInvoice($request, $clintID)
    {
        $invoice = new Invoice();

        $invoice->client_id = $clintID;
        $invoice->subtotal = $request->subtotal;
        $invoice->discount = $request->discount;
        $invoice->total = $request->total;
        $invoice->save();
    }

    public function client()
    {
        return $this->belongsTo(Client::class);
    }
}
