您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Account.php 2.4KB

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