⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
hospital.dev-unit.com
/
app
/
Repositories
/
View File Name :
InvoiceItemRepository.php
<?php namespace App\Repositories; use App\Models\Invoice; use App\Models\InvoiceItem; use Exception; /** * Class InvoiceItemRepository * * @version February 24, 2020, 5:57 am UTC */ class InvoiceItemRepository extends BaseRepository { /** * @var array */ protected $fieldSearchable = [ 'account_id', 'description', 'quantity', 'price', 'total', ]; /** * Return searchable fields */ public function getFieldsSearchable(): array { return $this->fieldSearchable; } /** * Configure the Model **/ public function model() { return InvoiceItem::class; } /** * @throws Exception */ public function updateInvoiceItem(array $invoiceItemInput, int $invoiceId) { /** @var Invoice $invoice */ $invoice = Invoice::find($invoiceId); $invoiceItemIds = []; foreach ($invoiceItemInput as $key => $data) { if (isset($data['id']) && ! empty($data['id'])) { $invoiceItemIds[] = $data['id']; $this->update($data, $data['id']); } else { /** @var InvoiceItem $invoiceItem */ $invoiceItem = new InvoiceItem($data); $invoiceItem = $invoice->invoiceItems()->save($invoiceItem); $invoiceItemIds[] = $invoiceItem->id; } } if (! (isset($invoiceItemIds) && count($invoiceItemIds))) { return; } InvoiceItem::whereNotIn('id', $invoiceItemIds)->whereInvoiceId($invoice->id)->delete(); } }