lemonsqueezy/plain-ui-components

Laravel 的 Plain UI 组件

v0.1.0 2023-05-11 12:19 UTC

This package is auto-updated.

Last update: 2024-09-11 15:54:26 UTC


README

Build Status Total Downloads Latest Stable Version License

一个基于 Laravel 的库,可以轻松构建 Plain UI 组件 卡片。

要求

  • PHP 8.1 或更高版本
  • Laravel 9.33 或更高版本

安装

使用 composer 安装此包

composer require lemonsqueezy/plain-ui-components

用法

/**
 * An Plain Customer Card endpoint
 *
 * @link https://docs.plain.com/adding-context/customer-cards
 */
public function customerCards(Request $request)
{
    abort_unless($email = $request->input('customer.email'), 400, 'No email provided.');

    $user = User::where('email', $email)->firstOrFail();

    return Cards::make()
        // Adding a card directly is easy, but the data is not guaranteed to be used by Plain.
        ->add(Card::make('platform-details')->add(Text::make('Platform Version: '.config('app.version')))

        // As an alternative, you can therefore use a binding, which lazily resolves
        // only when the request asks for that card, making it way more efficient.
        ->bind('user-details', fn (Card $card) => $this->buildUserDetailsCard($card, $user))

        // Finally, we'll render the cards payload using the JSON Request made by Plain.        
        ->toArray($request);
}

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全

如果您发现任何与安全相关的问题,请发送电子邮件至 hello@lemonsqueezy.com,而不是使用问题跟踪器。

这样,我们可以在合理的时间内安全地讨论和解决问题(同时避免用户面临不必要的额外风险)。一旦问题得到解决并发布新版本,我们将会确保对您的贡献表示感谢(除非您希望保持匿名)。

许可

MIT 许可证(MIT)。请参阅 许可文件 了解更多信息。