deegitalbe/trustup-pro-app-common

此包包含我们在应用程序之间共享的代码片段。

v2.6.0 2023-02-20 16:29 UTC

This package is auto-updated.

Last update: 2024-09-20 19:55:42 UTC


README

通过composer

composer require deegitalbe/trustup-pro-app-common

配置

环境

包期望您在 .env 文件中包含以下行

TRUSTUP_ADMIN_URL=
TRUSTUP_APP_KEY=
  • TRUSTUP_APP_KEY 密钥应为当前应用的唯一标识符。(例如:“tasks” 用于 taches.trustup.pro 应用程序)
  • TRUSTUP_ADMIN_URL 只应在开发模式下定义。(因为包已经为生产环境提供了正确的值)

安装命令

执行此命令以安装包并发布配置。

php artisan trustup_pro_app_common:install

然后您可以访问 config/trustup_pro_app_common.php 并正确配置它。

准备您的模型

您的模型应负责应用专业人员账户。通常它是 App\Models\System\Account.php

默认配置

实现接口

您的模型应实现此接口

Deegitalbe\TrustupProAppCommon\Contracts\AccountContract

使用默认特性

您可以在模型中使用此特性来自动同步

Deegitalbe\TrustupProAppCommon\Models\Synchronizable

自定义配置

实现接口

与默认配置步骤相同

自行定义接口方法

/**
 * Account database id.
 * 
 * @return int
 */
public function getId(): int;

/**
 * Account uuid that should be used to retrieve account details.
 * 
 * @return string
 */
public function getUuid(): string;

/**
 * Application key linked to account.
 * 
 * @return string
 */
public function getAppKey(): string;

/**
 * Professional authorization_key linked to account.
 * 
 * @return string
 */
public function getAuthorizationKey(): string;

/**
 * Subscription id linked to account.
 * 
 * @return string|null
 */
public function getSubscriptionId(): ?string;

/**
 * Subscription status linked to account.
 * 
 * @return string|null
 */
public function getSubscriptionStatus(): ?string;

/**
 * Account creation date.
 * 
 * @return Carbon
 */
public function getCreatedAt(): Carbon;

使用包特性监听模型事件

您可以在模型中使用此特性来监听其事件并在需要时做出反应

Deegitalbe\TrustupProAppCommon\Models\SynchronizeWhenSaved