[WIP] Working on orders & invoices
This commit is contained in:
54
app/Repositories/Shop/InvoicePayments.php
Normal file
54
app/Repositories/Shop/InvoicePayments.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\Shop\InvoicePayment;
|
||||
|
||||
class InvoicePayments
|
||||
{
|
||||
|
||||
public static function get($id, $relations = false)
|
||||
{
|
||||
return $relations ? InvoicePayment::with($relations)->findOrFail($id) : InvoicePayment::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return InvoicePayment::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 delete($id)
|
||||
{
|
||||
return InvoicePayment::destroy($id);
|
||||
}
|
||||
|
||||
public static function getPaymentType($id)
|
||||
{
|
||||
return self::PaymentTypes()[$id] ?? false;
|
||||
}
|
||||
|
||||
public static function PaymentTypes()
|
||||
{
|
||||
return [
|
||||
'',
|
||||
'CB',
|
||||
'CHEQUE',
|
||||
'VIREMENT',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user