PHP code example of laravilt / tables

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

    

laravilt / tables example snippets


use Laravilt\Tables\Table;
use Laravilt\Tables\Columns\TextColumn;
use Laravilt\Tables\Columns\BadgeColumn;
use Laravilt\Tables\Columns\ToggleColumn;
use Laravilt\Tables\Filters\SelectFilter;
use Laravilt\Tables\Actions\BulkAction;

Table::make()
    ->columns([
        TextColumn::make('name')
            ->searchable()
            ->sortable(),

        BadgeColumn::make('status')
            ->colors([
                'success' => 'active',
                'danger' => 'inactive',
            ]),

        ToggleColumn::make('is_featured'),
    ])
    ->filters([
        SelectFilter::make('status')
            ->options(['active', 'inactive']),
    ])
    ->toolbarActions([
        BulkAction::make('delete')
            ->label('Delete Selected')
            ->action(fn ($records) => $records->each->delete()),
    ]);