| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Services;
- use App\Models\Payment;
- use Illuminate\Database\Eloquent\Collection;
- class PaymentService
- {
- public function getAll(): Collection
- {
- return Payment::query()
- ->orderBy('created_at', 'desc')
- ->get();
- }
- public function findById(int $id): ?Payment
- {
- return Payment::find($id);
- }
- public function create(array $data): Payment
- {
- return Payment::create($data);
- }
- public function update(int $id, array $data): ?Payment
- {
- $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
- }
|