PHP code example of tkaratug / livewire-smart-table

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

    

tkaratug / livewire-smart-table example snippets


class UserList extends LivewireSmartTable
{
    $columns = [
        'id' => [
            'type' => 'string', // column type
            'name' => 'Id', // column header
            'class' => 'text-danger', // column class
        ],
        'name' => [
            'type' => 'string',
            'name' => 'Name',
        ],
        'email' => [
            'type' => 'string',
            'name' => 'E-Mail',
        ],
    ];
}

class UserController extends Controller
{
    public function index()
    {
        $users = App\User::where('is_active', '=', true)->get();

        return view('users', ['users' => $users]);
    }
}

$columns = [
    'profile' => [
        'type' => 'link',
        'url' => 'http://example.com/users/{id}/profile',
        'target' => '_blank'
    ],
];

'title' => [
    'type' => 'link',
    'url' => 'http://example.com/posts/{slug}',
];

'city' => [
    'type' => 'json',
    'name' => 'City', // Text for column header
    'from' => 'contact', // field that contains json data in a db table
    'value' => 'address.city' // nested json value
];

'actions' => [
    'type' => 'actions',
    'name' => 'Actions', // Text for column header
    'actions' => [
        [
            'element' => '<button>View</button>',
            'url' => 'http://example.com/users/{id}/profile'
        ],
        [
            'element' => '<button>Edit</button>',
            'url' => 'http://example.com/users/{id}/edit'
        ],
    ]
];

php artisan make:livewire UserList
bash
php artisan vendor:publish --tag=livewire-smart-table-views