PHP code example of dowhile / filament-tweaks

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

    

dowhile / filament-tweaks example snippets


// config/filament-tweaks.php
'features' => [
    'non_native_select' => true,   // Select::native(false) everywhere
    'center_form_actions' => false, // ...but keep form actions where they are
],

use Dowhile\FilamentTweaks\FilamentTweaksPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(FilamentTweaksPlugin::make());
}

'formats' => [
    'date' => 'd/m/Y',
    'time' => 'H:i:s',
    'datetime' => 'd/m/Y H:i:s',
    'currency' => 'ils',
    'timezone' => 'Asia/Jerusalem',
],

// config/filament-tweaks.php
'features' => [
    'hide_relation_managers_on_edit_pages' => true,        // every panel
    'hide_relation_managers_on_edit_pages' => ['admin'],   // …or only these panel IDs
],

public function getRelationManagers(): array
{
    return [];
}

use Dowhile\FilamentTweaks\Contracts\ShowsRelationManagers;

// Filament's default behaviour, i.e. everything from the resource's getRelations().
class EditOrder extends EditRecord implements ShowsRelationManagers {}

// Or declare the method yourself — anything you declare wins, including a subset.
class EditOrder extends EditRecord
{
    public function getRelationManagers(): array
    {
        return [OrderItemsRelationManager::class];
    }
}

// Make every column toggleable, keeping each column's own default visibility.
// Also caps the column manager height at 500px unless you set your own.
$table->columns([...])->allColumnsToggleable();

// Pass a condition (bool or closure) to apply it only sometimes; when it is
// false the table is left exactly as it was.
$table->columns([...])->allColumnsToggleable(auth()->user()->isAdmin());

// Panel-wide, from a service provider. Filament runs configureUsing() callbacks
// inside Table::make(), so the macro is reached before ->columns([...]) has been
// chained on - there is nothing to mutate yet, so it switches the default on one
// level down instead, at the column level, for every table built afterwards.
Table::configureUsing(fn (Table $table) => $table->allColumnsToggleable());

// Numeric input with a thousands-separator money mask, capped at 12 characters.
TextInput::make('price')->currencyMask();

// Textarea that grows with its content (via CSS `field-sizing`), with an optional max height.
Textarea::make('notes')->autogrow('20rem');

use Dowhile\FilamentTweaks\Filters\RangeFilter;
use Dowhile\FilamentTweaks\Filters\TextFilter;

// A single text input filtering the column with `like %value%`.
TextFilter::make('name');

// Any operator you like, and an optional numeric input.
TextFilter::make('code', '=');
TextFilter::make('quantity')->operator('>=')->numeric();

// Min/max inputs filtering the column with `>=` and `<=`.
RangeFilter::make('price');

use Dowhile\FilamentTweaks\Traits\HasActiveNavigationIcon;

class UserResource extends Resource
{
    use HasActiveNavigationIcon;

    protected static ?string $navigationIcon = 'heroicon-o-users';
}
bash
php artisan vendor:publish --tag="filament-tweaks-config"