| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
-
- namespace App\Models;
-
- use Carbon\CarbonInterface;
- use Illuminate\Database\Eloquent\Attributes\Fillable;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
-
- /**
- * A store's own Stripe account (Stripe Connect). Shoppers' payments go straight into it.
- *
- * @property int $id
- * @property int $store_id
- * @property string $account_id Stripe's id, such as acct_1Abc...
- * @property bool $charges_enabled Stripe lets the account take payments
- * @property bool $payouts_enabled Stripe pays the money into the merchant's bank
- * @property bool $details_submitted The merchant finished Stripe's sign-up form
- * @property bool $fpx_requested FPX (online banking) was asked for
- * @property bool $grabpay_requested GrabPay was asked for
- * @property CarbonInterface|null $checked_at When we last asked Stripe
- * @property CarbonInterface|null $created_at
- * @property CarbonInterface|null $updated_at
- * @property-read Store $store
- */
- #[Fillable(['account_id', 'charges_enabled', 'payouts_enabled', 'details_submitted', 'fpx_requested', 'grabpay_requested', 'checked_at'])]
- class StripeAccount extends Model
- {
- /**
- * @return BelongsTo<Store, $this>
- */
- public function store(): BelongsTo
- {
- return $this->belongsTo(Store::class);
- }
-
- /**
- * Malaysian payment methods asked for on the account, by our name, with the column that remembers it.
- * Cards are always on.
- */
- public const array METHODS = ['fpx' => 'fpx_requested', 'grabpay' => 'grabpay_requested'];
-
- /**
- * The methods not asked for yet.
- *
- * @return list<string>
- */
- public function methodsToRequest(): array
- {
- return array_keys(array_filter(self::METHODS, fn (string $column) => ! $this->{$column}));
- }
-
- /**
- * @return array<string, string>
- */
- protected function casts(): array
- {
- return [
- 'charges_enabled' => 'boolean',
- 'payouts_enabled' => 'boolean',
- 'details_submitted' => 'boolean',
- 'fpx_requested' => 'boolean',
- 'grabpay_requested' => 'boolean',
- 'checked_at' => 'datetime',
- ];
- }
- }
|