hocvt/orchid-livewire

A Livewire macro for Orchid Platform

v6.0.1 2023-03-28 07:49 UTC

This package is auto-updated.

Last update: 2024-11-28 11:27:20 UTC


README

GitHub Workflow Status styleci

Packagist Packagist Packagist

Package description: A Livewire macro for Orchid Platform

Installation

Install via composer

# for Orchid 12, 13
composer require livewire/livewire alexsabur/orchid-livewire:^5.2

# for Orchid 11
composer require livewire/livewire alexsabur/orchid-livewire:^4.0

# or for Orchid 10
composer require livewire/livewire alexsabur/orchid-livewire:^3.0

Publish orchid-livewire assets

php artisan vendor:publish --tag=orchid-livewire-assets

Publish original assets livewire (optional)

php artisan vendor:publish --tag=livewire:assets

Publish package config (optional)

php artisan vendor:publish --provider="AlexSabur\OrchidLivewire\ServiceProvider"

Usage

For Table and Sight

/**
 * @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}"),
    ];
}

For Screen

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

Security

If you discover any security related issues, please email alexsabur@live.ru instead of using the issue tracker.

Credits

This package is bootstrapped with the help of melihovv/laravel-package-generator.