| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Services;
- use App\Models\FinancialInvoice;
- use Illuminate\Database\Eloquent\Collection;
- class FinancialInvoiceService
- {
- public function getAll(): Collection
- {
- return FinancialInvoice::orderBy('created_at', 'desc')
- ->get();
- }
- public function findById(int $id): ?FinancialInvoice
- {
- return FinancialInvoice::find($id);
- }
- public function create(array $data): FinancialInvoice
- {
- return FinancialInvoice::create($data);
- }
- public function update(int $id, array $data): ?FinancialInvoice
- {
- $model = $this->findById($id);
- if (!$model) {
- return null;
- }
- $model->update($data);
- return $model->fresh();
- }
- public function delete(int $id): bool
- {
- $model = $this->findById($id);
- if (!$model) {
- return false;
- }
- return $model->delete();
- }
- // Add custom business logic methods here
- }
|