Bank.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Models;
  3. use App\Services\WithdrawalDestination;
  4. use Illuminate\Database\Eloquent\Builder;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. use Laravel\Sanctum\HasApiTokens;
  8. /**
  9. * Admin
  10. * @mixin Builder
  11. * @method static Builder|static where($column, $operator = null, $value = null, $boolean = 'and')
  12. * @method static Builder|static create($data)
  13. * @property $id
  14. * @property $member_id
  15. * @property $channel
  16. * @property $bank_name
  17. * @property $account
  18. * @property $card_no
  19. *
  20. */
  21. class Bank extends BaseModel
  22. {
  23. protected $table = 'banks';
  24. protected $fillable = ['member_id', 'channel', 'bank_name', 'bank_branch', 'account', 'card_no', 'qr_image'];
  25. protected $hidden = ['created_at', 'updated_at', 'alias'];
  26. public function getId()
  27. {
  28. return $this->id;
  29. }
  30. public function setMemberId($memberId): void
  31. {
  32. $this->member_id = $memberId;
  33. }
  34. public function getMemberId(): int
  35. {
  36. return $this->member_id;
  37. }
  38. public function getChannel(): string
  39. {
  40. return $this->channel;
  41. }
  42. public function getBankName(): string
  43. {
  44. return $this->bank_name;
  45. }
  46. public function getBankBranchAttribute(?string $value): ?string
  47. {
  48. if (!WithdrawalDestination::requiresBankBranch((string) $this->channel, (string) $this->bank_name)) {
  49. return null;
  50. }
  51. return $value ?? (trim((string) ($this->attributes['alias'] ?? '')) ?: null);
  52. }
  53. public function getAccount(): string
  54. {
  55. return $this->account;
  56. }
  57. public function getCardNo(): string
  58. {
  59. return $this->card_no;
  60. }
  61. }