Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

BankAccountObserver.php 1.6KB

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