Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Account.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace App\Models\Banking;
  3. use App\Casts\MoneyCast;
  4. use App\Models\Setting\Currency;
  5. use App\Traits\{Blamable, CompanyOwned};
  6. use Database\Factories\Banking\AccountFactory;
  7. use Illuminate\Database\Eloquent\Factories\{Factory, HasFactory};
  8. use Illuminate\Database\Eloquent\Model;
  9. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  10. use Spatie\Tags\HasTags;
  11. use Wallo\FilamentCompanies\FilamentCompanies;
  12. class Account extends Model
  13. {
  14. use Blamable;
  15. use CompanyOwned;
  16. use HasFactory;
  17. use HasTags;
  18. protected $table = 'accounts';
  19. protected $fillable = [
  20. 'company_id',
  21. 'type',
  22. 'name',
  23. 'number',
  24. 'currency_code',
  25. 'opening_balance',
  26. 'description',
  27. 'notes',
  28. 'status',
  29. 'bank_name',
  30. 'bank_phone',
  31. 'bank_address',
  32. 'bank_website',
  33. 'bic_swift_code',
  34. 'iban',
  35. 'aba_routing_number',
  36. 'ach_routing_number',
  37. 'enabled',
  38. 'created_by',
  39. 'updated_by',
  40. ];
  41. protected $casts = [
  42. 'enabled' => 'boolean',
  43. 'opening_balance' => MoneyCast::class,
  44. ];
  45. public function company(): BelongsTo
  46. {
  47. return $this->belongsTo(FilamentCompanies::companyModel(), 'company_id');
  48. }
  49. public function currency(): BelongsTo
  50. {
  51. return $this->belongsTo(Currency::class, 'currency_code', 'code');
  52. }
  53. public function createdBy(): BelongsTo
  54. {
  55. return $this->belongsTo(FilamentCompanies::userModel(), 'created_by');
  56. }
  57. public function updatedBy(): BelongsTo
  58. {
  59. return $this->belongsTo(FilamentCompanies::userModel(), 'updated_by');
  60. }
  61. public static function getAccountTypes(): array
  62. {
  63. return [
  64. 'checking' => 'Checking',
  65. 'savings' => 'Savings',
  66. 'money_market' => 'Money Market',
  67. 'certificate_of_deposit' => 'Certificate of Deposit',
  68. 'credit_card' => 'Credit Card',
  69. ];
  70. }
  71. public static function getAccountStatuses(): array
  72. {
  73. return [
  74. 'open' => 'Open',
  75. 'active' => 'Active',
  76. 'dormant' => 'Dormant',
  77. 'restricted' => 'Restricted',
  78. 'closed' => 'Closed',
  79. ];
  80. }
  81. protected static function newFactory(): Factory
  82. {
  83. return AccountFactory::new();
  84. }
  85. }