PHP code example of finity-labs / fin-modal-table-select
1. Go to this page and download the library: Download finity-labs/fin-modal-table-select 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/ */
finity-labs / fin-modal-table-select example snippets
use FinityLabs\FinModalTableSelect\Components\ModalTableSelect;
// Selected records as a table, columns inherited from the modal:
ModalTableSelect::make('categories')
->relationship('categories', 'name')
->multiple()
->tableConfiguration(CategoriesTable::class)
->displayAsTable()
// Invoice lines: pick products, edit quantity/price per row:
ModalTableSelect::make('product_picker')
->standalone(Product::class, 'name')
->multiple()
->tableConfiguration(ProductsTable::class)
->selectionOnly()
->fillsRepeater('items', fn (Product $record): array => [
'product_id' => $record->getKey(),
'name' => $record->name,
'unit_price' => $record->default_price,
'quantity' => 1,
], keyAttribute: 'product_id')
use Filament\Schemas\Components\Utilities\Get;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use FinityLabs\FinModalTableSelect\Components\ModalTableSelect;
use Illuminate\Support\Facades\Route;
class RoutesTable
{
public static function configure(Table $table): Table
{
return $table->columns([ // columns and filters only — no query;
TextColumn::make('label') // the component supplies the records itself
->searchable()
->sortable(),
TextColumn::make('route')->searchable(),
TextColumn::make('uri'),
TextColumn::make('panel')->badge(),
]);
}
}
ModalTableSelect::make('route_names')
->tableConfiguration(RoutesTable::class)
->standaloneRecords(fn (Get $get): array => collect(Route::getRoutes()->getRoutesByName())
->filter(fn ($route, string $name): bool => blank($get('panel')) || str_starts_with($name, "filament.{$get('panel')}."))
->map(fn ($route, string $name): array => [
'key' => $name,
'label' => (string) str($name)->afterLast('.')->headline(),
'route' => $name,
'uri' => '/'.$route->uri(),
'panel' => (string) str($name)->after('filament.')->before('.'),
])
->values()
->all(), titleAttribute: 'label')
->multiple()
->displayAsTable()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.