PHP code example of plokko / table-helper

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

    

plokko / table-helper example snippets


$table = TableHelper::table('users');

$table = TableHelper::table(User::where('id','>',0));

$table = TableHelper::table(new \plokko\ResourceQuery\ResourceQueryBuilder());

// TableHelper definition via fluent setters
$table
    ->column('id')// "id" column scope
    ->column('name')// "name" column scope
        ->label('User name')
        ->sort(true)
        ->filter(true)

    ->column('name')
        ->label('User name')
        ->sort(true)
        ->filter(true)

    ->column('email')
        ->label('E-mail')
        ->align('right')
        ->sort(true)
        ->filter(true)
        ->type('email')
        //->class('primary white--text')
        //->cellClass('primary lighten-5')

    ->column('created_age')
        ->label('Creation age')
        ->sort(true)
        ->field(\DB::raw('TIMESTAMPDIFF(HOUR,created_at,CURRENT_TIMESTAMP )'))

    ->column('actions')// No associated table field
        ->virtual()
        ->columnView('<v-btn @click="">Test {{item.id}}</v-btn>')

    ->setPageSize(30) /// Sets the number of elements per page
    
    ->autoselect(true)/// Automatically applies it to the table even if in field scope
    ;



if($request->ajax()){
    return $table;
}

//Use it in view
return view('your-view.example',compact('table'));

<!-- ...your view code... -->

    <!-- Renders the table in your view -->
    {{ $table->render() }}

<!-- ... -->