mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Extract business logic from remaining models to services
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.
This commit is contained in:
@@ -8,11 +8,16 @@ use App\Http\Requests\DeleteItemsRequest;
|
||||
use App\Http\Resources\ItemResource;
|
||||
use App\Models\Item;
|
||||
use App\Models\TaxType;
|
||||
use App\Services\ItemService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ItemsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ItemService $itemService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Retrieve a list of existing Items.
|
||||
*
|
||||
@@ -48,7 +53,7 @@ class ItemsController extends Controller
|
||||
{
|
||||
$this->authorize('create', Item::class);
|
||||
|
||||
$item = Item::createItem($request);
|
||||
$item = $this->itemService->create($request);
|
||||
|
||||
return new ItemResource($item);
|
||||
}
|
||||
@@ -75,7 +80,7 @@ class ItemsController extends Controller
|
||||
{
|
||||
$this->authorize('update', $item);
|
||||
|
||||
$item = $item->updateItem($request);
|
||||
$item = $this->itemService->update($item, $request);
|
||||
|
||||
return new ItemResource($item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user