PHP code example of lemonsqueezy / plain-ui-components

1. Go to this page and download the library: Download lemonsqueezy/plain-ui-components library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lemonsqueezy / plain-ui-components example snippets


/**
 * 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);
}