mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
New services: - ExchangeRateProviderService: CRUD, API status checks, currency converter URL resolution (extracted 122 lines from ExchangeRateProvider model) - FileDiskService: create, update, setAsDefault, validateCredentials (extracted 97 lines from FileDisk model) - ItemService: create/update with tax handling (extracted from Item model) - TransactionService: create/complete/fail (extracted from Transaction model) - CustomFieldService: create/update with slug generation (extracted from CustomField model) Controllers updated to use constructor-injected services: ExchangeRateProviderController, DiskController, ItemsController, CustomFieldsController.
31 lines
703 B
PHP
31 lines
703 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Facades\Hashids;
|
|
use App\Models\Transaction;
|
|
|
|
class TransactionService
|
|
{
|
|
public function create(array $data): Transaction
|
|
{
|
|
$transaction = Transaction::create($data);
|
|
$transaction->unique_hash = Hashids::connection(Transaction::class)->encode($transaction->id);
|
|
$transaction->save();
|
|
|
|
return $transaction;
|
|
}
|
|
|
|
public function complete(Transaction $transaction): void
|
|
{
|
|
$transaction->status = Transaction::SUCCESS;
|
|
$transaction->save();
|
|
}
|
|
|
|
public function fail(Transaction $transaction): void
|
|
{
|
|
$transaction->status = Transaction::FAILED;
|
|
$transaction->save();
|
|
}
|
|
}
|