Skip to content

Latest commit

 

History

History
160 lines (112 loc) · 4.71 KB

README.md

File metadata and controls

160 lines (112 loc) · 4.71 KB

Package to Print Filament Resources

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package adds a quick and simple way to print and print-as-pdf your Filament resource tables or forms, pretty handy to add basic reports (a lot of times it would be enough), it works with a any kind of sort, search, filter or paginated or all data.

Installation

You can install the package via composer:

composer require arielmejiadev/filament-printable

You can publish and run the stubs:

php artisan filament-printable:install

// or

php artisan vendor:publish --tag="filament-printable-stubs"

Usage

// Add print button in a filament list header

class ListUsers extends ListRecords
{
    protected function getHeaderActions(): array
    {
        return [
            // ...
            PrintAction::make(),
        ];
    }
}


// Add print button in Filament CreateRecord or EditRecord class

class EditUser extends EditRecord
{
    protected function getHeaderActions(): array
    {
        return [
            // ...
            \ArielMejiaDev\FilamentPrintable\Actions\PrintAction::make(),
        ];
    }
} 


// Add print button as a bulk action

->bulkActions([
    Tables\Actions\BulkActionGroup::make([
        Tables\Actions\DeleteBulkAction::make(),
        \ArielMejiaDev\FilamentPrintable\Actions\PrintBulkAction::make(),
    ]),
]);

Print Filament Tables

By default, filament-printable set print styles to make tables look good no matter if table has been:

  • Sorted
  • Show Search Results
  • Show Filter Results
  • Show Paginated Results
  • Show all results

The styles are easily to customize in public/css/filament-printable/filament-printable-styles.css

Print Filament Forms

By default Filament adds some flexible grids to form elements, if you want to set explicitly specific distribution for elements to print documents.

You can use Filament Grid and Section elements to distribute elements inside a form:

    public static function form(Form $form): Form
    {
        return $form
            ->schema([

                Forms\Components\Grid::make()->schema([
                    Forms\Components\TextInput::make('name'),
                    Forms\Components\TextInput::make('email'),
                ])->columns([
                        'xs' => 1,
                        'sm' => 2,
                    ]),

                Forms\Components\Section::make([
                    Forms\Components\TextInput::make('name'),
                    Forms\Components\TextInput::make('email'),
                    Forms\Components\TextInput::make('second_email'),
                ])->columns([
                        'xs' => 1,
                        'sm' => 3,
                    ]),
            ]);
    }

Important

For Letter and Legal paper sizes the Filament columns sm size distribution would be the one used.

Customization

Filament Printable includes some css styles to print your resources that most of the time looks awesome, but you can customize your print css to match your requirements, in public/css/filament-printable/filament-printable-styles.css

Here an example to remove some section styles to print:

.fi-section {
    background-color: transparent !important;
    box-shadow: none !important;
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.