You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BankAccountObserver.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Observers;
  3. use App\Enums\Accounting\AccountCategory;
  4. use App\Enums\Accounting\AccountType;
  5. use App\Models\Accounting\Account;
  6. use App\Models\Accounting\AccountSubtype;
  7. use App\Models\Banking\BankAccount;
  8. use Illuminate\Support\Facades\Log;
  9. class BankAccountObserver
  10. {
  11. /**
  12. * Handle the BankAccount "created" event.
  13. */
  14. public function created(BankAccount $bankAccount): void
  15. {
  16. //
  17. }
  18. /**
  19. * Handle the BankAccount "creating" event.
  20. */
  21. public function creating(BankAccount $bankAccount): void
  22. {
  23. //
  24. }
  25. /**
  26. * Get the default bank account subtype.
  27. */
  28. protected function getDefaultBankAccountSubtype(int $companyId, AccountType $type)
  29. {
  30. $subType = AccountSubtype::where('company_id', $companyId)
  31. ->where('name', 'Cash and Cash Equivalents')
  32. ->where('type', $type)
  33. ->first();
  34. if (!$subType) {
  35. $subType = AccountSubtype::where('company_id', $companyId)
  36. ->where('type', $type)
  37. ->first();
  38. }
  39. return $subType?->id;
  40. }
  41. /**
  42. * Handle the BankAccount "updated" event.
  43. */
  44. public function updated(BankAccount $bankAccount): void
  45. {
  46. //
  47. }
  48. /**
  49. * Handle the BankAccount "deleted" event.
  50. */
  51. public function deleted(BankAccount $bankAccount): void
  52. {
  53. //
  54. }
  55. /**
  56. * Handle the BankAccount "restored" event.
  57. */
  58. public function restored(BankAccount $bankAccount): void
  59. {
  60. //
  61. }
  62. /**
  63. * Handle the BankAccount "force deleted" event.
  64. */
  65. public function forceDeleted(BankAccount $bankAccount): void
  66. {
  67. //
  68. }
  69. }