PHP code example of hocvt / orchid-livewire

1. Go to this page and download the library: Download hocvt/orchid-livewire 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/ */

    

hocvt / orchid-livewire example snippets


/**
 * @return array
 */
public function columns(): array
{
    return [
        TD::set('status', __('Name'))
            ->sort()
            ->cantHide()
            ->filter(TD::FILTER_TEXT)
            ->livewire('user.pool-status'),

        // livewire will send an "email" with the key "email"
        TD::set('email', __('email'))
            ->livewire('user-email', key: fn (User $user) => "td-user-email-{$user->id}"),

        // livewire will be passed the model under the key 'user'
        TD::set('some_data', __('some data'))
            ->livewire('some-component', 'user', fn (User $user) => "td-some-data-{$user->id}"),

        TD::set('id', __('ID'))
            ->livewire('user.id', function (User $user) {
                return [
                    'user' => $user
                ];
            }, fn (User $user) => "td-user-{$user->id}"),
    ];
}

/**
 * Views.
 *
 * @return Layout[]
 */
public function layout(): array
{
    return [
        // With only user and role from query
        Layout::livewire('user.pay-status')
            ->only(['user', 'role']),

        // With except role from query
        Layout::livewire('foo')
            ->except('role'),

        // Without data from query
        Layout::livewire('baz')
            ->empty(),

        // With all from query
        Layout::livewire('baz'),
    ];
}
bash
php artisan vendor:publish --tag=orchid-livewire-assets
bash
php artisan vendor:publish --tag=livewire:assets
bash
php artisan vendor:publish --provider="AlexSabur\OrchidLivewire\ServiceProvider"